Created
September 8, 2012 17:33
-
-
Save jpayne/3677675 to your computer and use it in GitHub Desktop.
Start multiple Resque workers with Upstart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Correction: QUIT is the signal for a graceful shutdown. USR1 immediately kills the child.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry I didn't see your comment sooner, kesor. To restart the workers gracefully, I send a USR signal to the Resque workers via a Rake task, and then let Upstart bring them back up. Here's an example of the Rake task: