Best time to reboot server

(Dan Dascalescu) #1

I run a Discourse instance using one host, which needs to be rebooted from time to time in order for system updates to complete. How can I tell when the best time to reboot is, i.e. when there are fewest users with active sessions?

Also, if I reboot while a user is writing a post, what will happen to that post?

(maiki) #2

Would love to know if there was a way to hold off until a threshold or something, but having admin’d servers for quite a while I’ve never heard of such a thing.

When I run unattended-upgrades I normally figure out when I want to reboot, and set it in /etc/apt/apt.conf.d/50unattended-upgrades:

// If automatic reboot is enabled and needed, reboot at the specific
// time instead of immediately
//  Default: "now"
Unattended-Upgrade::Automatic-Reboot-Time "02:00";

To figure out the time that is best, just look at yer stats. I don’t see details like that in the default Discourse dashboard, but you should be able to use an external analytics system tell you when there are the least amount of people visiting your site. :slight_smile:

(Régis Hanol) #3

Drafts are automatically saved after 1 second of “pause”. So I wouldn’t worry too much about that.

If you want you can put the site in read-only for a little while before doing your OS upgrade.

(Felix Freiberger) #4

Also keep in mind that your server probably reboots very quickly. If a user is writing a reply during that time, he probably won’t notice it at all (only draft saving will be affected). If he tries to submit, he will get an error, but his reply won’t be lost – and if he retries 60 seconds later, your server will most likely be back up already :slight_smile:

(Jeff Atwood) #5

There might be some nginx logs query that would show you usage peaks, so you would know at what time to reboot for minimum usage.

Or if Google analytics is hooked up, you could use that for the same sort of query.