Gracefully shutting down sidekiq processes
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.
- Use
ps -ef | grep sidekiq
to find the pid - Create a file (e.g.,
sidekiq.pid
) with the only contents being the pid you just found sidekiqctl stop <pidfile_name>
- 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]