Created
November 8, 2011 15:07
-
-
Save railsbob/1347975 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 :delayed_job do | |
task :kill_stale_processes => :environment do | |
pid_list = IO::popen('ps aux|awk "{if (\$11 ~ \"delayed_job\") print \$2}"') | |
pids = pid_list.read.split(/\W+/) | |
pids.each do |pid| | |
%x[kill -9 #{pid}] | |
end | |
puts "Killed unresponsive delayed_job pids: #{pids.join(', ')}" if pids.any? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment