mperham/sidekiq — pull request #2100 by leshik (2014-12-25 19:48:04+00:00)
Title: Graceful shutdown - wait for workers to complete

In our company case, there are many time consuming tasks that shouldn't be killed by timeout, i.e. we need all workers to complete before stopping or restarting sidekiq. Besides that, I suppose it's a bit useless to send TERM signal right after USR1 (like shutdown method currently does) as workers don't have enough time to complete. I patched sidekiqctl to introduce new timeout option (stop_timeout, 60 sec by default) and ability to wait till workers complete. Now, when using shutdown, sidekiqctl will wait for all workers to complete and only then it will send the TERM signal. The whole operation is limited by the stop_timeout option.