monitoring multiple delayed job workers with monit
Asked Answered
C

1

6

I have read a lot about monitoring delayed_job with monit. The implementation is pretty easy and straight forward. But When one worker is not enough how do I setup monit to ensure that, let's say, 10 workers are constantly running?

Clothe answered 20/5, 2011 at 12:36 Comment(0)
P
7

You can just replicate the same config you have for the first worker N times. Suppose you have 5 workers, you'll monitor all of them with the following:

check process delayed_job.0
   with pidfile /path/to/shared/pids/delayed_job.0.pid
   start program = "/bin/su -c '/usr/bin/env RAILS_ENV=production /path/to/current/script/delayed_job -n 5 start' - user"
   stop program = "/bin/su -c '/usr/bin/env RAILS_ENV=production /path/to/current/script/delayed_job stop' - user"

check process delayed_job.1
   with pidfile /path/to/shared/pids/delayed_job.1.pid
   start program = "/bin/su -c '/usr/bin/env RAILS_ENV=production /path/to/current/script/delayed_job -n 5 start' - user"
   stop program = "/bin/su -c '/usr/bin/env RAILS_ENV=production /path/to/current/script/delayed_job stop' - user"

check process delayed_job.2
  with pidfile /path/to/shared/pids/delayed_job.2.pid
  start program = "/bin/su -c '/usr/bin/env RAILS_ENV=production /path/to/current/script/delayed_job -n 5 start' - user"
  stop program = "/bin/su -c '/usr/bin/env RAILS_ENV=production /path/to/current/script/delayed_job stop' - user"

check process delayed_job.3
  with pidfile /path/to/shared/pids/delayed_job.3.pid
  start program = "/bin/su -c '/usr/bin/env RAILS_ENV=production /path/to/current/script/delayed_job -n 5 start' - user"
  stop program = "/bin/su -c '/usr/bin/env RAILS_ENV=production /path/to/current/script/delayed_job stop' - user"

check process delayed_job.4
  with pidfile /path/to/shared/pids/delayed_job.4.pid
  start program = "/bin/su -c '/usr/bin/env RAILS_ENV=production /path/to/current/script/delayed_job -n 5 start' - user"
  stop program = "/bin/su -c '/usr/bin/env RAILS_ENV=production /path/to/current/script/delayed_job stop' - user"
Pilotage answered 31/5, 2011 at 13:21 Comment(3)
Doesn't this have the potential for issues if for example only delayed_job.4.pid goes down? Wouldn't it start 5 more nodes?Mceachern
@Mceachern no it will not, if you try to start 5 workers while for example 2 are already running, delayed_job will only start 3 new workers, and keep those first 2 running.Seaport
@NafaaBoutefer Thank you very much for that comment! I was not aware of this behavior and it saved me a lot of troubles. I verified with gist.githubusercontent.com/paneq/…Thermotaxis

© 2022 - 2024 — McMap. All rights reserved.