Skip to content

Instantly share code, notes, and snippets.

@xdougx
Forked from jpayne/Acknowledgement.txt
Created April 28, 2014 17:39
Show Gist options
  • Save xdougx/11378848 to your computer and use it in GitHub Desktop.
Save xdougx/11378848 to your computer and use it in GitHub Desktop.
Thanks to Jason Roelofs for his article at http://jasonroelofs.com/2012/03/12/manage-and-monitor-resque-with-upstart-and-monit/ which got me most of the way there.
description "Start a Resque worker by supplying an ID. For example: start resque ID=1. See also: resque-workers.conf"
respawn
respawn limit 5 20
instance $ID
script
APP_PATH=/apps/my_app/current
PIDFILE=$APP_PATH/tmp/pids/resque-$ID.pid
LOGFILE=$APP_PATH/log/resque_workers.log
su -c "cd $APP_PATH; bundle exec rake resque:work QUEUE=* PIDFILE=$PIDFILE RAILS_ENV=production >> $LOGFILE 2>&1" - my_user
end script
description "Start multiple Resque workers. Change NUM_WORKERS based on your needs."
start on (local-filesystems and net-device-up IFACE=eth0)
task
env NUM_WORKERS=5
script
for i in `seq 1 $NUM_WORKERS`
do
start resque-worker ID=$i
done
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment