Register now and start sharing your code snippets.
-->

How to get monit to start mongrel_rails properly

Shell Script (Bash) posted about 1 month ago by christian

Mongrel_rails and monit are not the best of friends. It’s difficult to get them to work together.

For example, this is the error I got in my monit logs when switching to a new mongrel_rails command that cleans up stale pids:

   1  'mongrel_1' process is not running
   2  'mongrel_2' trying to restart
   3  'mongrel_3' start: /usr/local/bin/mongrel_rails
   4  'mongrel_4' failed to start

To fix it I added the following start_command to the monit configuration:

   1  /usr/bin/env PATH=/usr/local/bin/:$PATH mongrel_rails cluster::start -C /var/www.... --clean --only 8000

The problem is that monit overrides the PATH environment variable, so it won’t find mongrel_rails unless you tell it where to find it.
Monit also contains a bug which doesn’t tell you why it can’t start mongrel_rails, but that’s another story…

Note that I’m using the —clean switch which will startup the mongrels even if a stale pid exists.

In fact I got so tired of the whole mess I wrote a plugin that generates a working monit configuration for mongrel_rails from one or more mongrel_cluster.yml configuration files.

Tagged mongrel_rails, monit, process, monitoring