Closed mshade closed 1 year ago
@mshade great suggestion. I'll prepare a PR.
Actually, I just looked at my old code again and realised that the server is already shutting down via SIGINT, so I'm not sure what this issue is about in the first place. 😄
There's an entire elaborate shutdown procedure that first sends SIGINT to the server, then waits a while for it to shutdown - if the server doesn't shut down it follows up with a SIGTERM and if that doesn't help finally a SIGKILL.
For details see: https://github.com/lloesche/valheim-server-docker/blob/192e806345e4a4a691bb3f34362954492a4a4c9b/valheim-server#L186-L214
Reverting the previous PR.
Ah - not sure how I missed that! Thanks for taking a look. I thought I got bit by this, went looking and didn't see this snippet.
Reference: https://valheimbugs.featureupvote.com/suggestions/159711/dedicated-server-does-not-save-world-on-sigterm
Supervisor can be told to issue SIGINT instead of SIGTERM which will allow valheim to exit cleanly and save world on shutdown. See docs here. This should be as simple as adding a section to supervisor config in the
valheim-server
section:Similarly, Dockerfile can declare a
STOPSIGNAL
if necessary - though supervisor may handle the shutdown properly if it knows to send SIGINT tovalheim-server
when supervisor itself receives a SIGTERM.