1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Automatically requeue messages for terminated workers, fixes GH-51

This commit is contained in:
Mike Perham 2012-02-22 16:54:38 -08:00
parent 07497eeed0
commit f2da181765
3 changed files with 14 additions and 2 deletions

View file

@ -1,6 +1,7 @@
master (unreleased)
HEAD
-----------
- Messages for terminated workers are now automatically requeued (mperham)
- Add support for Exceptional error reporting (bensie)
0.7.0

View file

@ -49,7 +49,13 @@ module Sidekiq
logger.info("Pausing 5 seconds to allow workers to finish...")
after(5) do
@busy.each(&:terminate)
#@busy.each(&:requeue)
redis.with_connection do |conn|
conn.multi do
@busy.each do |busy|
conn.lpush("queue:#{busy.queue}", busy.msg)
end
end
end
signal(:shutdown)
end
end
@ -66,6 +72,7 @@ module Sidekiq
watchdog('sidekiq processor_done crashed!') do
@done_callback.call(processor) if @done_callback
@busy.delete(processor)
processor.msg = processor.queue = nil
if stopped?
processor.terminate if processor.alive?
else
@ -91,6 +98,8 @@ module Sidekiq
if msg
processor = @ready.pop
@busy << processor
processor.msg = msg
processor.queue = queue
processor.process!(MultiJson.decode(msg), queue)
end
!!msg

View file

@ -23,6 +23,8 @@ module Sidekiq
end
end
attr_accessor :msg, :queue
def initialize(boss)
@boss = boss
redis.sadd('workers', self)