Skip to content

Instantly share code, notes, and snippets.

@gacha
Created November 7, 2012 11:45
Show Gist options
  • Save gacha/4031034 to your computer and use it in GitHub Desktop.
Save gacha/4031034 to your computer and use it in GitHub Desktop.
Resque monit config with passanger
check process resque-worker-production
with pidfile /home/webmaster/production/shared/pids/resque_worker.pid
start program = "/usr/bin/env HOME=/home/webmaster PATH=/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd /home/webmaster/production/current; nohup bundle exec rake environment resque:work RAILS_ENV=production PIDFILE=/home/webmaster/production/shared/pids/resque_worker.pid >> log/resque_worker.log 2>&1'" as uid webmaster and gid webmaster
stop program = "/bin/sh -c 'cd /home/webmaster/production/current && kill $(cat /home/webmaster/production/shared/pids/resque_worker.pid) && rm -f /home/webmaster/production/shared/pids/resque_worker.pid; exit 0;'"
if totalmem is greater than 300 MB for 10 cycles then
exec "/bin/kill -9 $(cat /home/webmaster/production/shared/pids/resque_worker.pid) && rm -f /home/webmaster/production/shared/pids/resque_worker.pid"
if 5 restarts within 5 cycles then timeout
group resque_workers
check process resque-worker-staging
with pidfile /home/webmaster/staging/shared/pids/resque_worker.pid
start program = "/usr/bin/env HOME=/home/webmaster PATH=/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd /home/webmaster/staging/current; nohup bundle exec rake environment resque:work RAILS_ENV=staging PIDFILE=/home/webmaster/staging/shared/pids/resque_worker.pid >> log/resque_worker.log 2>&1'" as uid webmaster and gid webmaster
stop program = "/bin/sh -c 'cd /home/webmaster/staging/current && kill -9 $(cat /home/webmaster/staging/shared/pids/resque_worker.pid) && rm -f /home/webmaster/staging/shared/pids/resque_worker.pid; exit 0;'"
if totalmem is greater than 300 MB for 10 cycles then
exec "/bin/kill -9 $(cat /home/webmaster/staging/shared/pids/resque_worker.pid) && rm -f /home/webmaster/staging/shared/pids/resque_worker.pid"
if 5 restarts within 5 cycles then timeout
group resque_workers
check file production-restart.txt with path /home/webmaster/production/current/tmp/restart.txt
if changed timestamp then
exec "/usr/bin/monit restart resque-worker-production"
check file staging-restart.txt with path /home/webmaster/staging/current/tmp/restart.txt
if changed timestamp then
exec "/usr/bin/monit restart resque-worker-staging"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment