# Properly shut down Discourse when host shuts down

**URL:** https://meta.discourse.org/t/properly-shut-down-discourse-when-host-shuts-down/34493
**Category:** Support
**Created:** [October 14, 2015, 10:00am UTC](https://meta.discourse.org/t/properly-shut-down-discourse-when-host-shuts-down/34493 "2015-10-14T10:00:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [October 14, 2015, 10:00am UTC](https://meta.discourse.org/t/properly-shut-down-discourse-when-host-shuts-down/34493/1 "2015-10-14T10:00:49Z")

</div>

About a year ago, @tobiaseigen asked how to properly shut down Discourse:

> [@tobiaseigen](#):
>
> Apologies for the newb question.
> 
> My preferred workflow has been to do a snapshot on the digitalocean dashboard before doing discourse updates, in case Bad Things Happen. As I am realizing now, just running `shutdown now -h` appears to not be enough and shuts down the server while docker is running. Do I need to run this instead?
> 
> ```
> cd /var/discourse && ./launcher stop app && shutdown now -h
> 
> ```
> 
> Is there a way to add this to a shutdown process so that the shutdown is clean? Or am I wrong in pinpointing this as the source of my woes? Is there another way my database could be getting corrupted?

The conclusion was that a `./launcher stop app` should now suffice. This is great, _but it still is a separate step_. It won’t help you if another sysadmin shuts down your system, or if `unattended-upgrades` decides that a reboot is due _now_.

Is there a way (on Ubuntu) to ensure that Discourse always shuts down properly if the system is rebooted?

---

<div class="post-metadata">

### Author: ![omfg](https://avatars.discourse-cdn.com/v4/letter/o/5e9695/32.png) [@omfg](https://meta.discourse.org/u/omfg)
#### Post date: [October 14, 2015, 10:35am UTC](https://meta.discourse.org/t/properly-shut-down-discourse-when-host-shuts-down/34493/2 "2015-10-14T10:35:37Z")

</div>

Discourse data is written to the host, so whatever has been written, will survive.  
Unless you’re on a very busy Discourse instance, I would say you could simply shutdown now.

On a _very_ busy Discourse instance, I’d stop Nginx and DB (in Docker) manually, then shutdown the app and OS. I’d probably make a script that runs these steps and you can do the same (`sudo ./shtudown-docker.sh` isn’t that hard).

---

<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: [October 14, 2015, 10:38am UTC](https://meta.discourse.org/t/properly-shut-down-discourse-when-host-shuts-down/34493/3 "2015-10-14T10:38:46Z")

</div>

Shutdown is safe, we have a shutdown sequence that docker triggers when stopped

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [October 14, 2015, 10:40am UTC](https://meta.discourse.org/t/properly-shut-down-discourse-when-host-shuts-down/34493/4 "2015-10-14T10:40:55Z")

</div>

> [@omfg](#):
>
> (sudo ./shtudown-docker.sh isn’t that hard)

I know – but this doesn’t protect against other sysadmins or `unattended-upgrades` 😄

> [@sam](#):
>
> Shutdown is safe, we have a shutdown sequence that docker triggers when stopped

This is great news. Thanks!

---

<div class="post-metadata">

### Author: ![omfg](https://avatars.discourse-cdn.com/v4/letter/o/5e9695/32.png) [@omfg](https://meta.discourse.org/u/omfg)
#### Post date: [October 14, 2015, 5:28pm UTC](https://meta.discourse.org/t/properly-shut-down-discourse-when-host-shuts-down/34493/5 "2015-10-14T17:28:00Z")

</div>

> [@fefrei](#):
>
> I know – but this doesn’t protect against other sysadmins or unattended-upgrades

You can disable unattended upgrades (on the OS level).  
And you could insert those steps in the system shutdown script.  
But Sam said they did that inside of the docker script.

---

<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:45pm UTC](https://meta.discourse.org/t/properly-shut-down-discourse-when-host-shuts-down/34493/6 "2024-06-08T12:45:57Z")

</div>

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