Monit, Mongrel, and /usr/local/bin

31 Jul 2009

If you're using Monit to restart a Mongrel cluster, you'll probably run into the problem detailed here - that is, Monit reports "execution failed" when trying to restart a mongrel instance. The problem is that mongrel_rails is usually in /usr/local/bin/, and Monit doesn't put /usr/local/bin in the PATH. That blog post's comments have a variety of suggestions and you'll find similar ideas around the web, such as:

That last suggestion seems fairly painless... but still clumsy.

So, here's another way. Are you compiling monit from source? Good! Edit env.c and change line 158:

/* BEFORE */
  char   *path = "PATH=/bin:/usr/bin:/sbin:/usr/sbin";
/*  AFTER */
  char   *path = "PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin";

A quick make && sudo make install and there you go! /usr/local/bin is now on the PATH. Enjoy!