Created
August 30, 2010 16:03
-
-
Save albus522/557606 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
worker = Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY']) | |
begin | |
worker.say "Starting job worker" | |
trap('TERM') { worker.say 'Exiting...'; $exit = true } | |
trap('INT') { worker.say 'Exiting...'; $exit = true } | |
loop do | |
result = nil | |
realtime = Benchmark.realtime do | |
result = worker.work_off | |
end | |
count = result.sum | |
break if $exit | |
if count.zero? | |
break | |
else | |
worker.say "#{count} jobs processed at %.4f j/s, %d failed ..." % [count / realtime, result.last] | |
end | |
break if $exit | |
end | |
ensure | |
Delayed::Job.clear_locks!(worker.name) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment