[Mongrel] Problems getting mongrel service working

Luis Lavena luislavena at gmail.com
Sun Feb 25 11:44:54 EST 2007


On 2/24/07, Jens-Christian Fischer <jcfischer at gmail.com> wrote:
> I have the same problems:
>
> C:\Documents and Settings\Administrator>mongrel_rails start -c "c:
> \Program Files
> \xxx\xxx" -p 3000 -e production
> ** Starting Mongrel listening at 0.0.0.0:3000
> ** Starting Rails with production environment...
> ** Rails loaded.
> ** Loading any Rails specific GemPlugins
> ** Signals ready.  INT => stop (no restart).
> ** Mongrel available at 0.0.0.0:3000
> ** Use CTRL-C to stop.
> ** INT signal received.
> Terminate batch job (Y/N)? y
>
>  >> At this point the application runs without problems
>
> C:\Documents and Settings\Administrator>mongrel_service console
> single -c "C:\Pr
> ogram Files\xxx\xxx" -p 3000 -e production -a 127.0.0.1 -B
> Mongrel Win32 Service, version 0.3.1
> (c) 2006 The Mongrel development team.
>
> Starting service 'single' in console mode, please wait...
> Service is in running state.
> Press Ctrl-C to stop it.
> Stop signal received, stopping...
> Waiting for onStart() to exit...
> Service stopped, doing cleanup.
> Done.
>
>  >> The application is not running - no log files generated
>

Ok, at this point I should say what previously posted to the list:
test the environment in the same conditions, with the same options!

In your first mongrel_rails call, you let mongrel choose the default
options for you. Under windows isn't possible right now, and debug
information is disabled (by default).

Now, when you tested the "console", you passed -B, debug mode, which
help you pinpoint some leacks of Ruby VM and your application.

In your statement, you said no log files where created, that is true,
but the application works???

> C:\Documents and Settings\Administrator>mongrel_rails service::remove
> -N xxx
>
> xxx service removed.
>
> C:\Documents and Settings\Administrator>mongrel_rails
> service::install -N xxx
> -c "C:\Program Files\xxx\xxx" -p 3000 -e production -a 127.0.0.1 -
> B -l log -p log
> Mongrel service 'xxx' installed as 'xxx'.
>

You passed "-l log" which is invalid, since -l expect a file and not a folder.
One important thing: -p is PORT parameter, and you used to pass your
PID (-p log), which will generate some problems, please review you
command parameters.

The service will fail, since if you type that command in plain mongrel_rails:

C:\Program Files\yyyy\zzzz>mongrel_rails start -c "C:\Program
Files\yyyy\zzzz" -p 3000 -e production -a 127.0.0.1 -B -l log -p log

** Starting Mongrel listening at 127.0.0.1:log
** Installing debugging prefixed filters. Look in log/mongrel_debug
for the files.

Its good to know that log port is always available! (sarcasm).

===

If I perform some checkings, I get everything working:

C:\Program Files\yyyy\zzzz>type config\environment.rb
...
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '1.1.6'
...


C:\Program Files\yyyy\zzzz>type config\database.yml
# SQLite version 3.x
#   gem install sqlite3-ruby
...
production:
  adapter: sqlite3
  database: db/production.sqlite3


# Test WEBrick
C:\Program Files\yyyy\zzzz>ruby script\server webrick -e production
./script/../config/boot.rb:28:Warning: require_gem is obsolete.  Use
gem instead.
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-02-25 13:03:25] INFO  WEBrick 1.3.1
[2007-02-25 13:03:25] INFO  ruby 1.8.4 (2005-12-24) [i386-mswin32]
[2007-02-25 13:03:25] INFO  WEBrick::HTTPServer#start: pid=1396 port=3000

Browsing to the default rails info page:
Ruby version	1.8.4 (i386-mswin32)
RubyGems version	0.9.2
Rails version	1.1.6
Active Record version	1.14.4
Action Pack version	1.12.5
Action Web Service version	1.1.6
Action Mailer version	1.2.5
Active Support version	1.3.1
Application root	C:/Program Files/yyyy/zzzz
Environment	production
Database adapter	sqlite3


# Now running mongrel_rails
C:\Program Files\yyyy\zzzz>mongrel_rails start --help
Usage: mongrel_rails <command> [options]
    -e, --environment ENV            Rails environment to run as
    -p, --port PORT                  Which port to bind to
    -a, --address ADDR               Address to bind to
    -l, --log FILE                   Where to write log messages
    -P, --pid FILE                   Where to write the PID
    -c, --chdir PATH                 Change to dir before starting
(will be expanded)
    -B, --debug                      Enable debugging mode

C:\Program Files\yyyy\zzzz>mongrel_rails start -c "C:\Program
Files\yyyy\zzzz" -p 3000 -e production -a 127.0.0.1
** Starting Mongrel listening at 127.0.0.1:3000
** Starting Rails with production environment...
C:0:Warning: require_gem is obsolete.  Use gem instead.
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready.  INT => stop (no restart).
** Mongrel available at 127.0.0.1:3000
** Use CTRL-C to stop.

# Browsing to that address:port report me the same results as previosly listed.

# Testing using 'console'
C:\Program Files\yyyy\zzzz>mongrel_service console single -e
production -p 3000 -a 127.0.0.1
Mongrel Win32 Service, version 0.3.1
(c) 2006 The Mongrel development team.

Starting service 'single' in console mode, please wait...
Service is in running state.
Press Ctrl-C to stop it.

# Browsing to the site show me the page, and also got the rails information too.
# Pressing Ctrl-C...

Stop signal received, stopping...
Waiting for onStart() to exit...
Service stopped, doing cleanup.
Done.

# Now install the service.
C:\Program Files\yyyy\zzzz>mongrel_rails service::install -N myservice
-c "C:\Program Files\yyyy\zzzz" -p 3000 -e production -a 127.0.0.1
** Copying native mongrel_service executable...
Mongrel service 'myservice' installed as 'myservice'.

# Verify the Executable Path (ImagePath) installed by service::install:
(Administrative Tools -> Services, locate 'myservice' and get properties):

"C:/Ruby/bin/mongrel_service.exe" single -e production -p 3000 -a
127.0.0.1 -l "log/mongrel.log" -P "log/mongrel.pid" -c "C:/Program
Files/yyyy/zzzz" -t 0 -r "public" -n 1024

# Now start the service.
C:\Program Files\yyyy\zzzz>net start myservice
The myservice service is starting.
The myservice service was started successfully.

# Check if ruby process is actually running:
C:\Program Files\yyyy\zzzz>tasklist /SVC /FI "SERVICES eq myservice"

Image Name                   PID Services
mongrel_service.exe          300 myservice


C:\Program Files\yyyy\zzzz>tasklist /FI "SERVICES eq myservice"

Image Name                   PID Session Name     Session#    Mem Usage
mongrel_service.exe          300 Console                 0      1.452 K


C:\Program Files\yyyy\zzzz>tasklist /FI "IMAGENAME eq ruby.exe"

Image Name                   PID Session Name     Session#    Mem Usage
ruby.exe                    1312 Console                 0     25.796 K


# With Process Explorer [1] you could see that ruby.exe process is a
child process of mongrel_service.exe

# Stopping the service
C:\Program Files\yyyy\zzzz>net stop myservice
The myservice service is stopping.
The myservice service was stopped successfully.


> C:\Documents and Settings\Administrator>net start xxx
> The xxx service is starting.
> The xxx service could not be started.
>

If you get this is because mongrel_service couldn't get ruby and
mongrel_rails to start properly.

Also, PLEASE REMEMBER that the default configuration for a service is
run under NT AUTHORITY\SYSTEM account, and NOT YOUR account.

That could show problems due NTFS permissions in your folders and/or files.

> Installed Gems:
>
> fastthread (0.6.4.1)
> gem_plugin (0.2.2)
> mongrel (1.0.1)
> mongrel_service (0.3.1)
> win32-service (0.5.2)
>
> and Rails 1.1.6
>

I mimic-ed your environment with the same gems, even reinstalled rails 1.1.6 :-)

> This is Windows 2003 Server
>

Tested under Windows XP SP2 and Windows Storage Server 2003 R2 (which
is the same, but optimized for file serving NAS like functionality).

> Any ideas?
>

Please, try perform the comparisons/tests with the same parameters.
Also check permission issues which often show no error but there are
present and brake almost every application "transparently".

Check this thread on Rubyforge about same problems with services under
managed environments:

http://rubyforge.org/forum/forum.php?thread_id=11060&forum_id=5450


[1] http://www.microsoft.com/technet/sysinternals/utilities/ProcessExplorer.mspx


Regards,

-- 
Luis Lavena
Multimedia systems
-
Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi


More information about the Mongrel-users mailing list