From 1d0f6b03dc868e1dd86c0f33efa8acf4291949b2 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Fri, 11 May 2012 21:25:38 -0700 Subject: [PATCH] Bloody hack to shutdown the Fetcher quickly, since Celluloid's terminate is not working as I expect --- Changes.md | 1 + lib/sidekiq/fetch.rb | 13 +++++++++++++ lib/sidekiq/manager.rb | 1 + 3 files changed, 15 insertions(+) diff --git a/Changes.md b/Changes.md index 292f56f1..217836e8 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,7 @@ 1.2.1 ----------- +- Fix issue with Fetcher slowing Sidekiq shutdown - Print backtraces for all threads upon INFO signal [#183] - Overhaul retries Web UI with new index page and bulk operations [#184] diff --git a/lib/sidekiq/fetch.rb b/lib/sidekiq/fetch.rb index cade3f43..efa09883 100644 --- a/lib/sidekiq/fetch.rb +++ b/lib/sidekiq/fetch.rb @@ -28,6 +28,8 @@ module Sidekiq # a new fetch if the current fetch turned up nothing. def fetch watchdog('Fetcher#fetch died') do + return if Sidekiq::Fetcher.done? + begin queue = nil msg = nil @@ -47,6 +49,17 @@ module Sidekiq end end + # Ugh. Say hello to a bloody hack. + # Can't find a clean way to get the fetcher to just stop processing + # its mailbox when shutdown starts. + def self.done! + @done = true + end + + def self.done? + @done + end + private # Creating the Redis#blpop command takes into account any diff --git a/lib/sidekiq/manager.rb b/lib/sidekiq/manager.rb index 5341d1de..d2754c03 100644 --- a/lib/sidekiq/manager.rb +++ b/lib/sidekiq/manager.rb @@ -39,6 +39,7 @@ module Sidekiq timeout = options[:timeout] @done = true + Sidekiq::Fetcher.done! @fetcher.terminate! if @fetcher.alive? logger.info { "Shutting down #{@ready.size} quiet workers" }