# Is it possible to restart Unicorn without downtime?

**URL:** https://meta.discourse.org/t/is-it-possible-to-restart-unicorn-without-downtime/65155
**Category:** Self-hosting
**Created:** [June 27, 2017, 12:37am UTC](https://meta.discourse.org/t/is-it-possible-to-restart-unicorn-without-downtime/65155 "2017-06-27T00:37:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![patrickbajao](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/patrickbajao/32/120896_2.png) [@patrickbajao](https://meta.discourse.org/u/patrickbajao)
#### Post date: [June 27, 2017, 12:37am UTC](https://meta.discourse.org/t/is-it-possible-to-restart-unicorn-without-downtime/65155/1 "2017-06-27T00:37:26Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [June 27, 2017, 12:45am UTC](https://meta.discourse.org/t/is-it-possible-to-restart-unicorn-without-downtime/65155/2 "2017-06-27T00:45:35Z")

</div>

> [@patrickbajao](#):
>
> Is it still safe to do that for Discourse?

Sort of, we do:

> <https://github.com/discourse/docker_manager/blob/main/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/main/lib/docker_manager/upgrader.rb#L28>

---

<div class="post-metadata">

### Author: ![patrickbajao](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/patrickbajao/32/120896_2.png) [@patrickbajao](https://meta.discourse.org/u/patrickbajao)
#### Post date: [June 27, 2017, 1:07am UTC](https://meta.discourse.org/t/is-it-possible-to-restart-unicorn-without-downtime/65155/3 "2017-06-27T01:07:17Z")

</div>

Ah. Sweet! That will do it. Thanks @sam! 🙂

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 27, 2017, 1:16am UTC](https://meta.discourse.org/t/is-it-possible-to-restart-unicorn-without-downtime/65155/4 "2017-06-27T01:16:17Z")

</div>

> 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?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [June 27, 2017, 1:20am UTC](https://meta.discourse.org/t/is-it-possible-to-restart-unicorn-without-downtime/65155/5 "2017-06-27T01:20:52Z")

</div>

Nope cause of:

> <https://github.com/discourse/discourse/blob/main/config/unicorn_launcher#L14-L24>

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 8, 2024, 12:44pm UTC](https://meta.discourse.org/t/is-it-possible-to-restart-unicorn-without-downtime/65155/6 "2024-06-08T12:44:36Z")

</div>

This topic was automatically closed after 2538 days. New replies are no longer allowed.
