-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server is not restarted after crash #8
Comments
Hi, see #14 for a poc |
Another possibility could be adding something to the screen that contains the minecraft process like: for (( ; ; ))
do
java -Xmx7G -jar minecraft_server.jar nogui
echo "Server closed unexpectedly, restarting in 10 seconds..."
sleep 10
done |
ive put in a very basic infinite while loop so the server process will now restart on crash, please pull down the latest image and let me know how it goes. |
Thanks for adding that @binhex I've tested that by pulling the latest image and:
each time the server automatically restarted so it seems like this patch works! Thanks. |
I have just realised that this patch unintentionally makes #12 a little worse to deal with. Whenever I want to gracefully shut down, I login to the web-ui and run stop, or run that in-game, wait for it to finish gracefully shutting down and then stop the container. Now however because it automatically restarts I'm worried there's no way to gracefully shut down as the server will auto-restart before you can stop the container 🤔 I'm not sure if there is a good solution to both problems at the same time. One approach is to run the save command before uncleanly exiting but it's not perfect. |
Maybe something like:
|
I shall put in additional code to trap SIGTERM and CTRL+C, this should then handle the case where you want to force a shutdown whilst still permitting the server to restart.
This is a different problem and has already been addressed, i am making use of dumb-init to pass signals along, i also have written a script to wait for the process to end which i will include to try and ensure the process is not sent a SIGKILL which should fix #12, it is a little tricky as there is a lot of wheels in wheels going on here. |
Thanks, sounds good. I'm happy to test the changes when you need. |
the changes are in, please pull down latest. |
@binhex I've pulled the latest image and tried to trigger a graceful shutdown, sadly I wasn't able to. Testing on Unraid. When I stop the container, the webUI immediately loses connection and the server stops immediately. I've checked the latest.log and the screen.log files and neither have any indication of the server gracefully stopping. Additionally, when logged into the server as a player, I get the error message "Disconnected - Connection lost" instead of "Disconnected - Server closed". If I shell into the container and do a |
Perhaps instead of running the java process inside a screen session, the infinite loop and the java command can run in a blocking fashion at the end of the start.sh script? I think because the current signal catching logic is inside the screen session it may not be receiving any signal, or the pid1 process is exiting immediately and not waiting for the screen to exit. It might be simpler if the subprocess isn't inside a screen, though that might break the way the webui works. Maybe also the root of the start.sh script could catch the signals and explicitly pkill java and wait for it. I recently saw this article which has some interesting information: https://sirikon.me/posts/0009-pid-1-bash-script-docker-container.html |
Potentially more powerful version of dumb-init which supports multiple children: https://github.com/linkdd/procfusion |
If the minecraft server process crashes, a manual restart of the container is required to get it back in working order. I would expect that either the minecraft server process is restarted automatically inside the container, or that the entire container goes down (so that it can be restarted by an orchestrator).
The text was updated successfully, but these errors were encountered: