<?xml version="1.0" encoding="UTF-8"?>
<snippet>
  <account-id type="integer">2</account-id>
  <body>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:

&lt;code&gt;
'mongrel_1' process is not running
'mongrel_2' trying to restart
'mongrel_3' start: /usr/local/bin/mongrel_rails
'mongrel_4' failed to start
&lt;/code&gt;

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

&lt;code&gt;
/usr/bin/env PATH=/usr/local/bin/:$PATH mongrel_rails cluster::start -C /var/www.... --clean --only 8000
&lt;/code&gt;

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 &quot;generates a working monit configuration for mongrel_rails&quot;:http://github.com/christianhellsten/monit_conf/ from one or more mongrel_cluster.yml configuration files.</body>
  <comments-count type="integer">0</comments-count>
  <created-at type="datetime">2008-11-17T01:57:25+02:00</created-at>
  <id type="integer">275</id>
  <language-id type="integer">131</language-id>
  <rendered-body>&lt;p&gt;Mongrel_rails and monit are not the best of friends. It&amp;#8217;s difficult to get them to work together.&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;mongrel_1&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt; process is not running
&lt;span class=&quot;line-numbers&quot;&gt;   2 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;mongrel_2&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt; trying to restart
&lt;span class=&quot;line-numbers&quot;&gt;   3 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;mongrel_3&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt; start: /usr/local/bin/mongrel_rails
&lt;span class=&quot;line-numbers&quot;&gt;   4 &lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;mongrel_4&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt; failed to start
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To fix it I added the following start_command to the monit configuration:&lt;/p&gt;
&lt;p&gt;&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;line-numbers&quot;&gt;   1 &lt;/span&gt; /usr/bin/env PATH=/usr/local/bin/:&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;$&lt;/span&gt;PATH&lt;/span&gt; mongrel_rails cluster::start -C /var/www.... --clean --only 8000
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The problem is that monit overrides the &lt;span class=&quot;caps&quot;&gt;PATH&lt;/span&gt; environment variable, so it won&amp;#8217;t find mongrel_rails unless you tell it where to find it.&lt;br /&gt;
Monit also contains a bug which doesn&amp;#8217;t tell you why it can&amp;#8217;t start mongrel_rails, but that&amp;#8217;s another story&amp;#8230;&lt;/p&gt;
&lt;p&gt;Note that I&amp;#8217;m using the &amp;#8212;clean switch which will startup the mongrels even if a stale pid exists.&lt;/p&gt;
&lt;p&gt;In fact I got so tired of the whole mess I wrote a plugin that &lt;a href=&quot;http://github.com/christianhellsten/monit_conf/&quot;&gt;generates a working monit configuration for mongrel_rails&lt;/a&gt; from one or more mongrel_cluster.yml configuration files.&lt;/p&gt;</rendered-body>
  <title>How to get  monit to start mongrel_rails properly</title>
  <updated-at type="datetime">2008-11-17T01:57:58+02:00</updated-at>
</snippet>
