我已经阅读了很多关于使用monit监视delayed_job的信息。实施非常简单直接。但是,如果一个工人还不够,我该如何设置monit以确保10个工人不断运行呢?
答案 0 :(得分:7)
您可以只为第一个工作人员复制相同的配置N次。 假设您有5名工人,您将使用以下内容监控所有工人:
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"