I ask this even though I technically know how to do it. I have after all set this environment up on 3 other servers. However, it is being incredibly, incredibly stubborn on this brand new install of RHEL6.
Here is an entry from my /etc/monit.d/sidekiq_uploader.monitrc
file:
# 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
Pretty simple, am I right? Doesn't work. Creates the pid file, creates the logfile in the Rails project log
directory, then nothing.
Perhaps the most frustrating thing is that I can cut and paste the start and stop commands above to the command line, and they run flawlessly.
In /var/monit/log
, over and over and over:
[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
Here's the only entry in the Rails log:
# Logfile created on 2016-05-18 12:37:21 -0400 by logger.rb/47272
Not helpful in the least. When I just run the start command at the command line:
The log is created in the Rails /log directory, AND the Rails production.log file is created. The sidekiq log file then contains:
# 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
For some unknown reason, I had to change the commands in the Monit configuration file to:
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
I have no idea why, but it works now.