View Full Version : About server downtime..

4th April 2014, 04:57
I have an idea that may help with the server downtime, and I'd write the script for you, but I have no clue how you have the server setup.
The script idea I have is to use a 30min. cron to check last logfile entry, and if it's the same line (server is frozen and thus not writing new entries), do a reboot of the server, to bring it back up from a hanging state.

Simple method would be using a variable/file to store the last line of the logfile at the end of the script, and at the beginning do a check against that to see if it matches or not. With timestamps, even if the message is the same, the line won't be, due to the date/time print at the beginning of the line.

Also, the server is currently down. 04:58CEST

4th April 2014, 08:42
The server last crashed 02:26 CEST, but it seems the restart script did not pick it up.
Normally it scans the log for certain crashes, just looking at the last line would not have helped in thise case, the server was happily printing lines in the log still.

J already has a script for that which scans for crashes in the logfile and tries to query the minecraft server for responses as well. Though occasionally the server hangs and there is no crash in the log and it is still responding to queries on the query port.

One thing that might be improved from reading it is the name of the logfile to check. Most of the time its ForgeModLoader-server-0.log, but for some reason the server sometimes uses another name:
ForgeModLoader-server-0.log ForgeModLoader-server-1.log ForgeModLoader-server-2.log
ForgeModLoader-server-0.log.1 ForgeModLoader-server-1.log.1 ForgeModLoader-server-2.log.1

So I guess the script could check which of those has the newest modification time and switch to that logfile, atm its ForgeModLoader-server-0.log.1 for example.

Atm the server still responds to query and the script is checking the wrong log file, so its not restarting it. I'll restart it by hand now.

4th April 2014, 09:49
Stupid Minecraft servers that crash are stupid :p

It's not as easy as it sound detecting whether a server is up or not. The best way is to just try to log on and see if you can. Unfortunately I don't know of a way to script that yet. Although I've seen someone who made an AI mod that could do it.

For now I'll go add another check to the startup scripts to also monitor for secondary ForgeModLoader log files.

4th April 2014, 09:51
Nearly done with that :)
Im making it check the most recently changed ForgeModloader log with /home/minecraft_tfc01/ForgeModLoader-server-?.log{,.?}

4th April 2014, 10:13
Good busy! (literal Dutch to English translations FTW!!)

4th April 2014, 10:42
It should check the most recent Forge log now, we'll just have to wait for the next server crash to see if it still works. Knowing TFC that should not take too long :tnt:

5th April 2014, 08:52
So far, there's been no problems with restarts after crashes, so nothing was broken! Though it's hard to say if that'll do the trick or not. We'll see in the next week or two whether it happens again or not. I'll be sure to leave a follow up post here if I happen to see it occur again.

9th April 2014, 16:47
Kodekat, I dont think that checking the log file and doing a simple string comparison is the way to go with this. A better choice would be to use .net or java to wrap the server with your own application and redirect STDOut and STDErr to this application, and have it monitor when the last read of the input stream returned. Its been a while since I last really looked at a MC server's output, but I dont remember there being a time stamp on the output. This would make it possible for the server to spit out the same message more than once, and dupe your scripts logic. If you decide to implement it this way, and want some examples, im sure I have code lying around that does exactly that.

IGN - mwolfert