Page 1 of 1

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

Posted: Mon Jan 22, 2018 10:59 pm
by holidaycontrol
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.

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

Posted: Tue Jan 30, 2018 1:14 am
by TeoTwawki

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)