Skip to content

Instantly share code, notes, and snippets.

@andreacfm
Created October 3, 2011 15:33
Show Gist options
  • Save andreacfm/1259382 to your computer and use it in GitHub Desktop.
Save andreacfm/1259382 to your computer and use it in GitHub Desktop.
resque workers via upstart runned by unpriviledge user
#!upstart
description "Workers [resque]"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
respawn
respawn limit 99 5
console none
script
su -c "source '/home/myuser/.rvm/scripts/rvm';rvm 1.9.2; cd /myapp/; RAILS_ENV={env} bundle exec rake resque:work QUEUE=* RESQUE_NAMESPACE={namespace} >> ~/resque_workers.log 2>&1" my_user
end script
$: rake queue:restart_workers
require 'resque/tasks'
task "resque:setup" => :environment
namespace :queue do
task :restart_workers => :environment do
pids = Array.new
Resque.workers.each do |worker|
pids << worker.to_s.split(/:/).second
end
if pids.size > 0
system("kill -QUIT #{pids.join(' ')}")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment