Search code examples
delayed-job

How to properly run monit with different workers


I am using different queues to manage delayed jobs and use monit to make sure that the workers are restarted if they get hung.

My question is, how do I properly setup monit to restart my worker with the right worker parameters given the following setup:

  • 1 worker for queue "priority"
  • 2 workers for for queue "default"

Right now I am hard coding pid 0 as the priority worker and passing it different parameters

check process delayed_job.0
   with pidfile /var/run/delayed_job.0.pid
   start program = "/bin/su -c 'bin/delayed_job --i 0 start --queue priority'"
   stop program = "/bin/su -c 'bin/delayed_job  --i 0 stop'"

check process delayed_job.1
   with pidfile /var/run/delayed_job.1.pid
   start program = "/bin/su -c 'bin/delayed_job --i 1 start --queue default'"
   stop program = "/bin/su -c 'bin/delayed_job  --i 1 stop'"

check process delayed_job.2
   with pidfile /var/run/delayed_job.2.pid
   start program = "/bin/su -c 'bin/delayed_job --i 2 start --queue default'"
   stop program = "/bin/su -c 'bin/delayed_job  --i 2 stop'"

Is there a less static way to scale this across many different queue types/worker configs?


Solution

  • The short form answer is no.

    There is no scaling function coming with monit. Every service you want watch has to be configured independently. This also makes a lot of sense if you look at the additional possibilities with monit, like specific load, io, net, etc. to any of the tasks.