Skip to content

Instantly share code, notes, and snippets.

@ijin
Created February 9, 2012 14:19
Show Gist options
  • Save ijin/1780296 to your computer and use it in GitHub Desktop.
Save ijin/1780296 to your computer and use it in GitHub Desktop.
resque drain_pool
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