我问这个,即使我在技术上知道如何做到这一点。毕竟我已经在其他3台服务器上设置了这个环境。然而,在这个全新安装的RHEL6上,它令人难以置信地非常顽固。
以下是我的/etc/monit.d/sidekiq_uploader.monitrc
文件中的条目:
# sidekiq worker 0
check process sidekiq_uploader_0
with pidfile /var/run/sidekiq/uploader/sidekiq_0.pid
start program = "/home/deploy/scripts/sidekiq uploader start production 0" with timeout 180 seconds
stop program = "/home/deploy/scripts/sidekiq uploader stop production 0" with timeout 180 seconds
group uploader_sidekiq
很简单,我是对的吗?不行。创建pid文件,在Rails项目log
目录中创建日志文件,然后什么也不创建。
也许最让人沮丧的是我可以将上面的开始和停止命令剪切并粘贴到命令行,然后它们完美地运行。
在/var/monit/log
中,一遍又一遍:
[EDT May 18 12:37:29] info : Awakened by User defined signal 1
[EDT May 18 12:37:29] info : 'sidekiq_uploader_0' start: /home/deploy/scripts/sidekiq
[EDT May 18 12:37:29] info : 'sidekiq_uploader_0' start action done
[EDT May 18 12:37:59] error : 'sidekiq_uploader_0' process is not running
[EDT May 18 12:37:59] info : 'sidekiq_uploader_0' trying to restart
这是Rails日志中唯一的条目:
# Logfile created on 2016-05-18 12:37:21 -0400 by logger.rb/47272
至少没有帮助。当我在命令行运行start命令时:
在Rails / log目录中创建日志,并创建Rails production.log文件。然后sidekiq日志文件包含:
# Logfile created on 2016-05-18 12:37:21 -0400 by logger.rb/47272
2016-05-18T17:45:13.303Z 24843 TID-oxfx4u7ko INFO: Booting Sidekiq 4.0.2 with redis options {:url=>"redis://redis:6379", :namespace=>"uploader"}
2016-05-18T17:45:14.061Z 24843 TID-oxfx4u7ko INFO: Running in ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
2016-05-18T17:45:14.061Z 24843 TID-oxfx4u7ko INFO: Sidekiq Pro 3.0.1 / Sidekiq Enterprise 1.1.0, commercially licensed.
2016-05-18T17:45:14.064Z 24843 TID-oxfx4u7ko INFO: Starting processing, hit Ctrl-C to stop
2016-05-18T17:45:14.126Z 24843 TID-oxfxm4ix8 INFO: Gained leadership of the cluster
答案 0 :(得分:0)
由于某些未知原因,我不得不将Monit配置文件中的命令更改为:
start program = "/bin/bash -c '/home/deploy/scripts/sidekiq uploader start production 0 &>/home/deploy/sidekiq_0.out'" with timeout 180 seconds
stop program = "/bin/bash -c '/home/deploy/scripts/sidekiq uploader stop production 0'" with timeout 180 seconds
我不明白为什么,但它现在有效。