[Mongrel] mongrel_cluster and Monit

Jack Baty jbaty at fusionary.com
Tue Feb 27 09:56:49 EST 2007

On one of my development servers mongrel dies when idle for any length
of time. Since I've not been able to solve that problem I thought I'd
route around it by using monit to kick things when necessary.

My monitrc contains the following...

check process mongrel_8310 with pidfile
  group mongrel
  start program = "/usr/local/bin/mongrel_rails cluster::start -C
/home/valleyc/apps/cms/dev/current/config/mongrel_cluster.yml --clean
--only 8310"
  stop program = "/usr/local/bin/mongrel_rails cluster::stop -C
/home/valleyc/apps/cms/dev/current/config/mongrel_cluster.yml --clean
--only 8310"

  if failed host port 8310 protocol http
    with timeout 10 seconds
    then restart

  if totalmem > 128 Mb then restart
  if cpu is greater than 60% for 2 cycles then alert
  #if cpu > 90% for 5 cycles then restart
  #if loadavg(5min) greater than 10 for 8 cycles then restart
  if 3 restarts within 5 cycles then timeout

If I run the start command manually it works fine. When run via monit
however it seems unable to find mongrel_rails....

# monit validate
'mongrel_8310' process is not running
'mongrel_8310' trying to restart
'mongrel_8310' start: /usr/local/bin/mongrel_rails
'mongrel_8310' failed to start
starting port 8310
command not found: mongrel_rails start -d -e production -a
-c /home/valleyc/apps/cms/dev/current --user valleyc --group valleyc
-p 8310 -P /home/valleyc/apps/cms/dev/current/log/mongrel.8310.pid -l

No amount of $PATH fiddling seemed to help, so for now I've patched
mongrel_cluster's init.rb by changing line 62 (of version
from this...

argv = [ "mongrel_rails" ]

to this...

argv = [ "/usr/local/bin/mongrel_rails" ]

...which works, but seems less than ideal. Any suggestions for a
better way to fix this without messing with the mongrel_cluster code
would be appreciated.



Jack Baty                  http://jackbaty.com/    (616) 822-5800
Fusionary                  http://fusionary.com/   (616) 454-2357
820 Monroe N.W. Suite 212
Grand Rapids, MI 49503

More information about the Mongrel-users mailing list