Skip to content
mperham edited this page Apr 5, 2012 · 13 revisions

Sidekiq uses several signals to control its lifecycle.

USR1

USR1 tells Sidekiq it will be shutting down at some point in the near future. It will stop accepting new work but continue working on current messages.

TERM

TERM signals that Sidekiq should shut down within the -t timeout option. Any workers that do not finish within the timeout are forcefully terminated and their messages are lost. The timeout defaults to 5 seconds since all Heroku processes must exit within 10 seconds.

Capistrano

The capistrano integration sends USR1 at the very start of the deploy and sends TERM at the end of the deploy in order to give the maximum amount of time for Sidekiq workers to finish their work. Since a Capistrano deploy might take 60 seconds or more, often the timeout defaults are fine because all the workers have finished their current job by the time TERM is signalled.

You can set :sidekiq_timeout in your deploy.rb to configure a longer timeout:

set :sidekiq_timeout, 15

sidekiqctl

Sidekiq ships with a control executable for shutting it down.

sidekiqctl [quiet|stop|shutdown] [path-to-pidfile] [timeout]

The Capistrano integration does this:

# start of deploy
# sends USR1
sidekiqctl quiet [pidfile]
# ... deploy happens ...
# sends TERM with a hard deadline to kill -9
sidekiqctl stop [pidfile] [sidekiq_timeout]

Alternatively you can do the same thing with a single shutdown command:

sidekiqctl shutdown [pidfile] 60

This sends TERM, waits up to 60 seconds and then will kill -9 the Sidekiq process if it still has not exited.

Clone this wiki locally