Is it possible to restart Unicorn without downtime?

Hi,

I know that we can use sv stop unicorn then sv start unicorn to restart unicorn workers. But that will cause downtime. Killing the master with a USR2 signal is the usual way to do hot restart, as far as I know. Is it still safe to do that for Discourse? Or is there a better way to do this?

I understand that I rarely (or not at all) have to do this. But just want to know in case of emergency.

Thanks!

4 Likes

Sort of, we do:

https://github.com/discourse/docker_manager/blob/master/lib/docker_manager/upgrader.rb#L121

So you would send the USR2 to the unicorn launcher that will forward the signal for you.

https://github.com/discourse/docker_manager/blob/master/lib/docker_manager/upgrader.rb#L28

7 Likes

Ah. Sweet! That will do it. Thanks @sam! :slight_smile:

USR2 - reexecute the running binary. A separate QUIT should be sent to the original process once the child is verified to be up and running.

@sam According to the docs, don’t we need to send a QUIT as well?

2 Likes

Nope cause of:

https://github.com/discourse/discourse/blob/master/config/unicorn_launcher#L14-L24

3 Likes