I previously had Monit monitoring resque with the following Monit script
check process resque_worker_production_QUEUE
with pidfile /var/tmp/resque_production.pid
start program = "/usr/bin/env HOME=/home/eg RACK_ENV=production PATH=/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd /apps/eg/production/current; nohup bundle exec rake environment resque:work RAILS_ENV=production QUEUE=mailer VERBOSE=1 PIDFILE=/var/tmp/resque_production.pid & >> log/resque_worker_production_QUEUE.log 2>&1'" as uid eg and gid eg
stop program = "/bin/sh -c 'cd /apps/eg/production/current && kill -9 $(cat
Then I changed some things around, most notably removing the system-wide rvm install and I'm assuming a ruby install at /usr/local/ruby/bin . Around this time monit could no longer start resque. Maybe the cause was something else but I'm thinking it was these uninstalls that caused the breakage.
So I looked throught the script and noticed that /usr/local/ruby/bin doesn't exist, so I tried changing it to what I think it should point to now that the ruby in my rvm is the only one around /home/eg/.rvm/rubies/ruby-1.9.3-p194/bin
But that didn't work. So I google some more and found this suggestion which also didn't work:
check process resque_worker_production_QUEUE
with pidfile /var/tmp/resque_production.pid
start program = "/bin/bash -l -c 'cd /apps/eg/production/current; nohup bundle exec rake environment resque:work RAILS_ENV=production QUEUE=mailer VERBOSE=1 PIDFILE=/var/tmp/resque_production.pid & >> log/resque_worker_production_QUEUE.log 2>&1'" as uid eg and gid eg
All I get in the log is:
[UTC Oct 5 03:06:38] error : 'resque_worker_production_QUEUE' process is not running
[UTC Oct 5 03:06:38] info : 'resque_worker_production_QUEUE' trying to restart
[UTC Oct 5 03:06:38] info : 'resque_worker_production_QUEUE' start: /bin/bash
[UTC Oct 5 03:07:08] error : 'resque_worker_production_QUEUE' failed to start
So I'm not sure how to debug this further. Any suggestions?
To be sure, do you have RVM loading script in bash files? Something like:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
For me it works with:
check process <%= pid_name %>
with pidfile <%= pid %>
start program = "/bin/bash -c -l -i 'cd <%= current_path %> && NEWRELIC_ENABLE=false HOME=/home/<%= resque_user %> RAILS_ENV=<%= rails_env %> QUEUE=<%= queue %> PIDFILE=<%= pid %> BACKGROUND=yes VERBOSE=1 <%= fetch(:bundle_cmd, "bundle") %> exec rake resque:work >> <%= shared_path %>/log/resque.log 2>&1'" as uid <%= resque_user %> and gid <%= resque_group %> with timeout 180 seconds
I see difference in -i flag , not sure if it's required, and in order of env variables
Have you checked resque logs ? (log/resque_worker_production_QUEUE.log as I see)
Another thing to try is to run this command after ssh'ing to server as root (or another monit user), sudo su won't be enough as you'll already have rvm loaded, so better try from scratch. It can reveal some errors.
Also check out this page http://rvm.io/integration/cron for tips
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.