Jay Caines-Gooby

Back in 5 mins

Monit managing mongrels

Tuesday September 21, 2010 @ 11:14 AM (BST)

Like everybody else, I was getting the dreaded “Execution failed” from monit when it couldn’t restart a mongrel which had gone out-of-bounds on its monitoring settings.

The solution that worked for me was the env and $PATH line:

start program = "/usr/bin/env PATH=/bin:/usr/local/bin:$PATH \
                   ruby mongrel_rails cluster::start \
                                      -C /etc/mongrel_cluster/myapp.yml \
                                      --clean --only 8000"
stop program = "/usr/bin/env PATH=/bin:/usr/local/bin:$PATH \
                   ruby mongrel_rails cluster::stop \
                                      -C /etc/mongrel_cluster/myapp.yml \
                                      --only 8000"

But what scuppered me and will hopefully help you, is that whilst trying the various options suggested by Google, I wasn’t reloading the monit config. Doh!

So if you’re trying to debug your failing mongrels under monit here are a couple of tips…

Start a new shell, and unset your PATH to mimic how monit behaves:

sh
unset PATH

Now you can test your monit stop/start lines (you’ll need to sudo as monit normally runs as root)…

/usr/bin/sudo /usr/bin/env PATH=/bin:/usr/local/bin:$PATH \
    mongrel_rails cluster::stop \
      -C /etc/mongrel_cluster/myapp.yml \
      --only 8000

/usr/bin/sudo /usr/bin/env PATH=/bin:/usr/local/bin:$PATH \
    mongrel_rails cluster::start \
      -C /etc/mongrel_cluster/myapp.yml \
      --clean \
      --only 8000

If that works for you, then you can be pretty sure that it’ll work for monit, as long as you remember to reload your monit config after making the changes.

Comments

Thanks for this post. I followed your approach and worked through to a working start and stop command.
The resulting start and stop on my servers is very similar but not exactly the same as the one you’ve posted.

Gravatar icon
Mike King
Thursday December 02, 2010 @ 09:19 PM (GMT)
New comment

required, won't be displayed

optional

Don't type anything here unless you're an evil robot:


And especially don't type anything here:

Basic XHTML (including links) is allowed, just don't try anything fishy. Your comment will be auto-formatted unless you use your own <p> tags for formatting. You're also welcome to use Textile.

Copyright © 2011 Jay Caines-Gooby. All rights reserved.
Powered by Thoth.