Created
February 9, 2012 14:19
-
-
Save ijin/1780296 to your computer and use it in GitHub Desktop.
resque drain_pool
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
desc "Stops the pool proccess" | |
task :drain_pool do | |
begin | |
Dir.glob(Rails.root.join('tmp', 'pids').join('resque_workers_pc.pid').to_s) do |pidfile| | |
begin | |
pid = File.read(pidfile).to_i | |
Process.kill("QUIT", pid) | |
Rails.logger.info "Pooling process #{pid} ended" | |
rescue Errno::ESRCH => e | |
Rails.logger.info "Stale #{pidfile}" | |
# ensure | |
# FileUtils.rm pidfile, :force => true | |
end | |
end | |
exit(0) | |
rescue Exception => e | |
exit(0) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment