Skip to content
bartolsthoorn edited this page Feb 19, 2013 · 13 revisions

Sidekiq responds to several signals.

TTIN

Sidekiq will respond to SIGTTIN by printing backtraces for all threads in the process. This is useful for debugging if you have a Sidekiq process that appears to be dead or stuck.

kill -TTIN [worker_pid]

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.

USR2

Sidekiq will reopen its log file for logrotate

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 8 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.

The Sidekiq TERM timeout is set in config/sidekiq.yml or with the -t parameter. Sidekiq will do its best to exit by this timeout when it receives TERM.

:timeout: 30

sidekiqctl

Sidekiq ships with a control executable for shutting it down.

sidekiqctl [quiet|stop] [path-to-pidfile] [deadline_timeout]

The Capistrano integration does this:

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

Alternatively you can do the same thing with a single stop command but you'll want to give your worker time to finish their current jobs.

sidekiqctl stop [pidfile] 60

This sends TERM, waits up to 60 seconds and then will kill -9 the Sidekiq process if it has not exited by then. Keep in mind the deadline timeout is the amount of time sidekiqctl will wait before running kill -9 on the Sidekiq process. It's different from Sidekiq's timeout and should be set longer so Sidekiq is not killed before it has a chance to exit normally.

Clone this wiki locally