[Linux] Watchdog script, auto crash recovery

lukasni

New Member
Jul 29, 2019
19
0
0
Hey all

I have recently been having problems with my horizons server freezing up, still trying to track down the cause, but that's not the issue here. Due to those crashes, I decided it would be nice to set up some kind of auto-recovery script that will detect if the client is crashed and restart it if need be.

Now, if the actual java process has died that is pretty simple, just check if the pid is still active and restart if not. However, most of the crashes I have been getting were actually not crashing the process, the process was just hanging and bogging up the CPU of my server.

I'm thinking of maybe checking the timestamp of the last log message, that should never be more than 5 minutes due to autosaving, but that seems a bit clunky.

Does anyone have a good way of dealing with the problem?
 
  • Like
Reactions: Connor Gavitt

Francis Baster

New Member
Jul 29, 2019
295
0
0
I have a python script which repeatedly asks the server for its player count and message of the day, and if the server is unable to respond to 15 consecutive requests a restart command is sent to my server wrapper (remote toolkit). I have found that this is the most reliable means of crash-detection. My script simply stuffs the .forcerestart command into the screen session which contains my server, causing Minecraft Remote Toolkit to kill the java process and then start a new one. If you do not use remote toolkit then you will need to modify the restart command that is to be executed by the shell. This should be easy enough to do, just execute pkill to identify and kill the server process, or perhaps just use the screen command to kill the appropriate screen session, then issue a command to start a new server process inside a screen session.

http://paste.ubuntu.com/7259805/
 
Last edited: