[BDS-437] Should handle SIGINT and SIGTERM signals Created: 27/Jan/19 Updated: 09/Aug/20 Resolved: 10/Feb/20 |
|
| Status: | Resolved |
| Project: | Bedrock Dedicated Server |
| Affects Version/s: | 1.8.1.2 |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Miguel | Assignee: | Unassigned |
| Resolution: | Invalid | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Bedrock server should handle signals like SIGTERM and SIGINT for Linux like Java edition does. One of the benefits of doing that is that we can set bedrock server as a system service and it'll stop gracefully whenever the admin wants to stop the service or the system is shutting down. Currently when it receives any of these signals it closes the server instantly without having the opportunity of cleaning up the server and it may lead to world corruption or worse. |
| Comments |
| Comment by IonicEcko [ 10/Feb/20 ] |
|
Could a mod please link to |
| Comment by Michael Petter [ 30/Jan/19 ] |
|
In the meantime, you can wrap the server in a shell script to handle SIGTERM and shutdown the server gracefully by issuing a "stop" command. It ain't pretty, but it works... Here's the dash script I use. (do not run with bash!) set -e pipe=/run/minecraft/pipe.$$ mkfifo $pipe exec 3<> $pipe rm $pipe <&3 3>&- LD_LIBRARY_PATH=. ./bedrock_server & pid=$! exec >&3 3<&- trap 'echo stop' INT TERM trap : CHLD while read -r line; do echo $line; done wait $pid exit $? |
| Comment by Michael Petter [ 30/Jan/19 ] |
|
+1 on this. I believe SIGINT is already handled (Ctrl-C in terminal will log the "Quit correctly" message); however, SIGTERM is definitely NOT handled, and this makes dockerizing more difficult as well. |