Last active
December 18, 2015 18:19
-
-
Save lardawge/5824847 to your computer and use it in GitHub Desktop.
Restart resque workers on capistrano deploy
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
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 |
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
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