Skip to content

Instantly share code, notes, and snippets.

@lardawge
Last active December 18, 2015 18:19
Show Gist options
  • Save lardawge/5824847 to your computer and use it in GitHub Desktop.
Save lardawge/5824847 to your computer and use it in GitHub Desktop.
Restart resque workers on capistrano deploy
desc "Kill resque workers"
task :kill_processes, :roles => :god, :on_no_matching_servers => :continue do
run "cd #{deploy_to}/current && rake resque:restart_workers RAILS_ENV=#{rails_env}" do |ch, stream, data|
puts data
end
end
end
namespace :resque 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