我正在尝试添加一个通过以下方式进行监控的进程monit
:
check process sidekiq_worker_flow with pidfile /home/flio/apps/stage-flow/current/tmp/pids/sidekiq-1.pid
start program = "cd /home/flio/apps/stage-flow/current && source /etc/profile.d/rbenv.sh && bundle exec sidekiq -i 1 -e staging --pidfile /home/flio/apps/stage-flow/current/tmp/pids/sidekiq-1.pid --logfile /home/flio/apps/stage-flow/shared/log/sidekiq-1.log --daemon" as uid flio
stop program = "cd /home/flio/apps/stage-flow/current && bundle exec sidekiqctl stop /home/flio/apps/stage-flow/current/tmp/pids/sidekiq-1.pid 10" as uid flio
if 5 restarts within 15 cycles then timeout
看起来“启动程序”的命令从未被调用,因为我尝试调用一些调试命令(echo 'bla bla' > ~/monint_debug.log')但从未得到任何东西。我还运行命令(在 root 下)手动启动和停止 - 并且它工作正常。我还有另一个类似的脚本:
check process sidekiq_worker_2
with pidfile /var/www/flio/current/tmp/pids/sidekiq-1.pid
start program = "/bin/su -lc 'cd /var/www/flio/current && source /etc/profile.d/rbenv.sh && bundle exec sidekiq -i 1 -e production --pidfile /var/www/flio/current/tmp/pids/sidekiq-1.pid --logfile /var/www/flio/shared/log/sidekiq-1.log --daemon -C /var/www/flio/current/config/sidekiq_2.yml' flio"
stop program = "/bin/su -lc 'cd /var/www/flio/current && bundle exec sidekiqctl stop /var/www/flio/current/tmp/pids/sidekiq-1.pid 10' flio"
if 5 restarts within 15 cycles then timeout
而且效果很好。