Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is how I got this working.</p> <ol> <li>Use the <a href="http://github.com/collectiveidea/delayed_job" rel="nofollow noreferrer">collectiveidea fork of delayed_job</a> besides being actively maintained, this version has a nice <code>script/delayed_job</code> daemon you can use with monit. Railscasts has <a href="http://railscasts.com/episodes/171-delayed-job" rel="nofollow noreferrer">a good episode</a> about this version of <code>delayed_job</code> (<a href="http://asciicasts.com/episodes/171-delayed-job" rel="nofollow noreferrer">ASCIICasts version</a>). This script also has some other nice features, like the ability to run multiple workers. I don't cover that here.</li> <li>Install monit. I installed from source because Ubuntu's version is so ridiculously out of date. I followed <a href="http://dambalah.com/2009/05/05/install-monit-from-source-on-ubuntu/" rel="nofollow noreferrer">these instructions</a> to get the standard init.d scripts that come with the Ubuntu packages. I also needed to configure with <code>./configure --sysconfdir=/etc/monit</code> so the standard Ubuntu configuration dir was picked up.</li> <li><p>Write a monit script. Here's what I came up with:</p> <p><code>check process delayed_job with pidfile /var/www/app/shared/pids/delayed_job.pid</code><br/> <code>start program = "/var/www/app/current/script/delayed_job -e production start"</code><br/> <code>stop program = "/var/www/app/current/script/delayed_job -e production stop"</code><br/></p> <p>I store this in my soucre control system and point monit at it with <code>include /var/www/app/current/config/monit</code> in the <code>/etc/monit/monitrc</code> file.</p></li> <li>Configure monit. <a href="http://www.ubuntugeek.com/monitoring-ubuntu-services-using-monit.html" rel="nofollow noreferrer">These instructions</a> are laden with ads but otherwise OK.</li> <li>Write a task for capistrano to stop and start. <code>monit start delayed_job</code> and <code>monit stop delayed_job</code> is what you want to run. I also reload monit when deploying to pick up any config file changes.</li> </ol> <p>Problems I ran into:</p> <ol> <li><code>daemons</code> gem must be installed for <code>script/delayed_job</code> to run. </li> <li>You must pass the Rails environment to <code>script/delayed_job</code> with <code>-e production</code> (for example). This is documented in the README file but not in the script's help output.</li> <li>I use Ruby Enterprise Edition, so I needed to get monit to start with that copy of Ruby. Because of the way <a href="https://stackoverflow.com/questions/257616/sudo-changes-path-why">sudo handles the PATH</a> in Ubuntu, I ended up symlinking <code>/usr/bin/ruby</code> and <code>/usr/bin/gem</code> to the REE versions.</li> </ol> <p>When debugging monit, I found it helps to stop the init.d version and run it from the th command line, so you can get error messages. Otherwise it is very difficult to figure out why things are going wrong.</p> <pre><code>sudo /etc/init.d/monit stop sudo monit start delayed_job </code></pre> <p>Hopefully this helps the next person who wants to monitor <code>delayed_job</code> with monit.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload