Gracefully shutting down sidekiq processes Gracefully shutting down sidekiq processes ruby ruby

Gracefully shutting down sidekiq processes


Use this to kill sidekiq forcefully.

ps -ef | grep sidekiq | grep -v grep | awk '{print $2}' | xargs kill -9


Sidekiq provides the ability to specify a pidfile at start time or, as shown below, to create the pidfile after the process has been started. In either case you can then use the pidfile at stop time.

  1. Use ps -ef | grep sidekiq to find the pid
  2. Create a file (e.g., sidekiq.pid) with the only contents being the pid you just found
  3. sidekiqctl stop <pidfile_name>
  4. Use -P <pidfile_name> or --pidfile <pidfile_name> when starting sidekiq in the future


Just been looking into this one myself...

Seems like newer versions of Sidekiq have this built in:

https://github.com/mperham/sidekiq/wiki/Signals

kill -USR1 [PROCESS_ID]

Worked great for me. The workers stopped picking up new jobs, but finished the ones they were on, then I finally killed the process when it was done.

kill -TERM [PROCESS_ID]