Server Question - Script to record log and then auto start s

Post Reply
holidaycontrol
Posts: 15
Joined: Mon Jan 15, 2018 10:02 am

Server Question - Script to record log and then auto start s

Post by holidaycontrol » Mon Jan 22, 2018 10:59 pm

Hi everyone,

What is the best way to detect a DSGame-server.exe crash, record to log file, wait 5 seconds, force close and reopen (automated)? Thanks and sorry for the bother, I'm not great at coding/scripts.

Thanks in advance.

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: Server Question - Script to record log and then auto sta

Post by TeoTwawki » Tue Jan 30, 2018 1:14 am

Code: Select all

@echo off
cd ..
:onCrash
echo [%date% %time%] Restarting Server...
DSGame-server.exe --ip 127.0.0.1 --port 54230 --log .\log\Main_Map.log
echo Server was stopped or crashed!
GOTO onCrash
Change exe name, comments, ip and port as needed (you can run multiple map servers).
Save as .cmd file type, I keep mine in a folder named batch I tossed in the repository root so if you run it form elsewhere you will need to change that "cd .." line.

It is also possible to to run all your exe's out of just one cmd script with a few adjustments, google can help. I prefer mien separate so I can more easily manually restart 1 without the others being affected. There are 3rd party programs to restart things, but I feel that is overkill for such a trivial thing.

ps:
something like echo %date% %time%> .\log\Last_Main_Map_Stop.log just before the GOTO would record the last time a crash or restart happened, but you could also just look at the timestamp on the crashdump (you are saving crash dumps aren't you? that's automate-able to! see HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps in regedit and google)
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

Post Reply