librelist archives

« back to archive

Hot restart of sidekiq

Hot restart of sidekiq

From:
Manu J
Date:
2014-06-13 @ 19:56
I want to start a new instance of sidekiq without waiting for the old
sidekiq process to shut down completely. There has been some previous
discussion around this (
http://librelist.com/browser//sidekiq/2013/4/16/restarting-sidekiq-the-smart-way/
)

Here is what was proposed by Mike Perham in the original thread,

1. Send the original process a TERM (with a long timeout)
2. Start a new process (I assume the same pid file can be used)

Things are a bit more complex when using monit/upstart. If using monit,
there is a potential for a race condition if original process shuts down
much before the new process is started and if monit tries to restart it
before us.

To avoid that, we can do this,

1. Send the original process a TERM (with a long timeout)
2. Remove the pid file

This will make monit spin up a new sidekiq process. if the monit checking
interval is low,
then this is as good as hot restart. if it is high, then an explicit "monit
restart  sidekiq" call can be made.

Is there a better way to achieve a hot restart with monit ?

Regards
Manu