title: Monitoring resque with monit with RVM
body: <p>I previously had Monit monitoring resque with the following Monit script</p>
  
  <pre><code>check process resque_worker_production_QUEUE
    with pidfile /var/tmp/resque_production.pid
    start program = "/usr/bin/env HOME=/home/eg RACK_ENV=production PATH=/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd /apps/eg/production/current; nohup bundle exec rake environment resque:work RAILS_ENV=production QUEUE=mailer VERBOSE=1 PIDFILE=/var/tmp/resque_production.pid &amp; &gt;&gt; log/resque_worker_production_QUEUE.log 2&gt;&amp;1'" as uid eg and gid eg
    stop program = "/bin/sh -c 'cd /apps/eg/production/current &amp;&amp; kill -9 $(cat 
  </code></pre>
  
  <p>Then I changed some things around, most notably removing the system-wide rvm install and I'm assuming a ruby install at /usr/local/ruby/bin . Around this time monit could no longer start resque. Maybe the cause was something else but I'm thinking it was these uninstalls that caused the breakage.</p>
  
  <p>So I looked throught the script and noticed that /usr/local/ruby/bin doesn't exist, so I tried changing it to what I think it should point to now that the ruby in my rvm is the only one around /home/eg/.rvm/rubies/ruby-1.9.3-p194/bin</p>
  
  <p>But that didn't work. So I google some more and found this suggestion which also didn't work:</p>
  
  <pre><code>check process resque_worker_production_QUEUE
    with pidfile /var/tmp/resque_production.pid
    start program = "/bin/bash -l -c 'cd /apps/eg/production/current; nohup bundle exec rake environment resque:work RAILS_ENV=production QUEUE=mailer VERBOSE=1 PIDFILE=/var/tmp/resque_production.pid &amp; &gt;&gt; log/resque_worker_production_QUEUE.log 2&gt;&amp;1'" as uid eg and gid eg
  </code></pre>
  
  <p>All I get in the log is:</p>
  
  <pre><code>[UTC Oct  5 03:06:38] error    : 'resque_worker_production_QUEUE' process is not running
  [UTC Oct  5 03:06:38] info     : 'resque_worker_production_QUEUE' trying to restart
  [UTC Oct  5 03:06:38] info     : 'resque_worker_production_QUEUE' start: /bin/bash
  [UTC Oct  5 03:07:08] error    : 'resque_worker_production_QUEUE' failed to start
  </code></pre>
  
  <p>So I'm not sure how to debug this further. Any suggestions?</p>