Monit未能重启sidekiq

时间:2015-10-06 10:55:52

标签: ruby-on-rails centos sidekiq monit

我试图让monit在CentOS服务器上重启我的sidekiq服务。在尝试了多种解决方案后,我感到难过,仍未能启动该服务。

来自monit.d的我的sidekiq文件:

check process sidekiq
  with pidfile /var/www/App/tmp/pids/sidekiq.pid
  start program = "/bin/bash -l -c 'sudo cd /var/www/App && bundle exec sidekiq --index 0 --pidfile /var/www/App/tmp/pids/sidekiq.pid --environment production --logfile /var/www/App/log/sidekiq.log --daemon'" as uid deploy and gid deploy
  stop program = "/bin/bash -l -c 'cd /var/www/App && bundle exec sidekiqctl stop /var/www/App/tmp/pids/sidekiq.pid 10'" as uid deploy and gid deploy
  if totalmem is greater than 512 MB for 2 cycles then restart
  if 3 restarts within 5 cycles then timeout

如果我手动运行启动程序命令,它启动sidekiq罚款,但monit似乎没有做任何事情。刚出现:

[BST Oct  6 11:51:17] error    : 'sidekiq' process is not running
[BST Oct  6 11:51:17] info     : 'sidekiq' trying to restart
[BST Oct  6 11:51:17] info     : 'sidekiq' start: /bin/bash
[BST Oct  6 11:52:47] error    : 'sidekiq' failed to start

所以它包含文件很好,但不知何为没有设法从脚本启动服务。

它能是什么?某些权限问题排序?

3 个答案:

答案 0 :(得分:0)

您需要更新到最新的Monit版本(5.14)。 删除当前的monit安装并按照以下说明操作:

https://rtcamp.com/tutorials/monitoring/monit/

希望它有所帮助!

PS:在这里找到解决方案:https://bitbucket.org/tildeslash/monit/issues/109/failed-to-stop-always-after-60-seconds

答案 1 :(得分:0)

根据Debugging monit

我发现我需要设置PATH。

我的开始计划:

  

/ bin / bash -c' cd / home / vagrant / apps / skylark / current; PATH = / home / vagrant / .rbenv / shims:/home/vagrant/.rbenv/bin:$ PATH bundle exec sidekiq -d -e production -C -P / home / vagrant / apps / skylark / shared / tmp / pids /sidekiq.pid -L /home/vagrant/apps/skylark/shared/log/sidekiq.log'

答案 2 :(得分:0)

我认为问题出在您的用户身上。您需要使用部署用户执行。

check process sidekiq
  with pidfile /var/www/App/tmp/pids/sidekiq.pid
  start program = "/bin/su - deploy -c 'sudo cd /var/www/App && bundle exec sidekiq --index 0 --pidfile /var/www/App/tmp/pids/sidekiq.pid --environment production --logfile /var/www/App/log/sidekiq.log --daemon'" as uid deploy and gid deploy
  stop program = "/bin/su - deploy -c 'cd /var/www/App && bundle exec sidekiqctl stop /var/www/App/tmp/pids/sidekiq.pid 10'" as uid deploy and gid deploy
  if totalmem is greater than 512 MB for 2 cycles then restart
  if 3 restarts within 5 cycles then timeout