Jump to content

[41.78] [Multiplayer] Zomboid Dedicated Server Does Not Handle SIGTERM


Tripodzomboid
 Share

Recommended Posts

• Version?

• Singleplayer/Multiplayer?

• Host or dedicated?

• Mods?

• Old or new save?

   • Reproduction steps:

 

• 41.78

• Multiplayer

• Dedicated

• No Mods

• N/A

• Reproduction steps:

Start a Zomboid server on Linux, and send SIGTERM(Signal 15) to it's PID, expected behavior should be a graceful exit (should be equivalent to "quit"), but instead the server will terminate ungracefully and not properly save.

 

See: https://dsa.cs.tsinghua.edu.cn/oj/static/unix_signal.html

Edited by Tripodzomboid
grace to graceful
Link to comment
Share on other sites

I'm not well versed in Linux, so could you explain this a little more?

Just from looking at the manual, I'm not sure what the practical difference would be for the game? The JVM will already create its own core dump if its exited abnormally, so having it sent to console output doesn't seen necessary. We also don't use any additional shutdown hooks (which seems to be what'd cause SIGTERM  in java) and instead use System.exit().

Link to comment
Share on other sites

19 hours ago, EnigmaGrey said:

I'm not well versed in Linux, so could you explain this a little more?

Just from looking at the manual, I'm not sure what the practical difference would be for the game? The JVM will already create its own core dump if its exited abnormally, so having it sent to console output doesn't seen necessary. We also don't use any additional shutdown hooks (which seems to be what'd cause SIGTERM  in java) and instead use System.exit().

 

SIGTERM is usually understood to be a friendly request for a program to exit, which is why it is allowed to be caught and ignored. Catching SIGTERM and nicely exiting will allow the Zomboid server to be managed correctly by SystemD (init system), which sends SIGTERMS to manage daemons and processes, as many linux server owners might want to manage their server as a daemon (how many servers are managed, like http, ssh, sftp etc...), and prevent data loss for example if a sysadmin reboots their system without properly saving their Zomboid server, as systemd will send SIGTERM to processes to ask them to close for a reboot (a stop job), if for some reason the server can't exit correctly systemD will eventually send SIGKILL (unfriendly).

 

Perhaps this is already the functionality though and I am doing something wrong? Does system.exit() properly save the world file? I believe this issue caused me a world rollback as I manage my Zomboid server as a daemon, which the wiki recommends.

 

 

Edited by Tripodzomboid
Clarification, and reason for the bug report, and proper reply.
Link to comment
Share on other sites

Okay, I think I get what you mean: the pz server isn’t designed to be a  background service. It instead depends on console input to function and will not operate gracefully without it.

 

You need to enter the save and then quit commands in the console  to ensure it shuts down correctly.

 

 This is something we could look at changing in the future now that we’re aware of it, but I really must caution against running the server this way. I feel the wiki may be giving troublesome advice in this case.

Link to comment
Share on other sites

2 hours ago, EnigmaGrey said:

Okay, I think I get what you mean: the pz server isn’t designed to be a  background service. It instead depends on console input to function and will not operate gracefully without it.

 

You need to enter the save and then quit commands in the console  to ensure it shuts down correctly.

 

 This is something we could look at changing in the future now that we’re aware of it, but I really must caution against running the server this way. I feel the wiki may be giving troublesome advice in this case.

Running a server this way makes remote administration significantly easier, as the only other way to handle a remote server and do other tasks on the same machine during the same remote session is to use a terminal multiplexer like GNU Screen or tmux. but even if you disagree with this usecase handling SIGTERM will provide some valuable safeties against other SIGTERM scenarios such as an accidental system reboot.

Edited by Tripodzomboid
Spelling and Clarification
Link to comment
Share on other sites

tl;dr: No, I agree. I think it'd be best for us to add signal handling in the future and one of the devs we've just hired is heavily involved with Linux. He'll be looking into it. It'll not be something that we can do until Build 42, though. Until then the PZ server needs to be treated the way it's designed: as a console application instead of a service.

 

Long version:

 

It's really not that I disagree or that I don't think we should do it.

 

It's that I didn't know this was a "thing" with Java until this conversation. It's just something at least I, personally, have never encountered before (outside of a bit of C++). It's in our interest to support this however, as it explains a few issues we've encountered over the years when supporting users (that is, some likely tried exactly this -- some that offer paid hosting -- without realizing that not all applications are able to handle this without expressly being designed for it).

So as the program is now, it has to be shut down with the console commands. From looking at the Wiki, I believe this is also what you discovered, hence the addition of zombie.command?

If you can work it out so that you first send save, wait 10-15 seconds, then send quit, you should not risk data loss until we can sort this.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...