after many lost logs due to crashes/batch restarts, I decided to add a backup function to the nice batch script I've been using, originated from ButchCassidy of TWB found here over at the RO forums. it's been tested for a while and seems pretty sound, though I have added a bunch of features to it since then, and my server has been oddly stable recently.
all functions should work fine with any nt5+ windows os. the idea behind the way I have organised it is, that it should work with any conventional kf-ucc install, no additional config required. only thing you may need to edit is the command line, same like you would for the default kf_server_launcher.bat. simply paste it into KFserver.bat or somesuch, drop into the kf system directory and you're set. then create shortcuts to it elsewhere or edit the log locations further to your preference.
what it does:
- check for ucc.exe (make sure it's run in proper dir)
- create a new .\logs dir in system for all batch logs if one does not exist
- log each start/restart
- backup current log on each start/restart in yymmdd-hhmmss format
- auto restart on exit/error
caveats:
- this is not a rotation script, I considered that but there are situations where your ucc might loop on restart (ie. busted mutators, bad maps/configs, etc.) which would then erase your logs again.
- since there is no rotation you will have to watch out for the log bloat, ie. problem maps/mutators that generate a ton of warnings/errors (eg. kf-asylum), and reclaim space if it gets out of hand. it's done this way so that you will always have a chance to inspect them, and provide info if you need help.
- all variables point to relative locations, so if you want to run it elsewhere you will of course need to modify it accordingly
command line section in red, adjust it to your needs if you have custom settings that need to be run on start.
all functions should work fine with any nt5+ windows os. the idea behind the way I have organised it is, that it should work with any conventional kf-ucc install, no additional config required. only thing you may need to edit is the command line, same like you would for the default kf_server_launcher.bat. simply paste it into KFserver.bat or somesuch, drop into the kf system directory and you're set. then create shortcuts to it elsewhere or edit the log locations further to your preference.
what it does:
- check for ucc.exe (make sure it's run in proper dir)
- create a new .\logs dir in system for all batch logs if one does not exist
- log each start/restart
- backup current log on each start/restart in yymmdd-hhmmss format
- auto restart on exit/error
caveats:
- this is not a rotation script, I considered that but there are situations where your ucc might loop on restart (ie. busted mutators, bad maps/configs, etc.) which would then erase your logs again.
- since there is no rotation you will have to watch out for the log bloat, ie. problem maps/mutators that generate a ton of warnings/errors (eg. kf-asylum), and reclaim space if it gets out of hand. it's done this way so that you will always have a chance to inspect them, and provide info if you need help.
- all variables point to relative locations, so if you want to run it elsewhere you will of course need to modify it accordingly
command line section in red, adjust it to your needs if you have custom settings that need to be run on start.
Code:
@echo off
:: batch title and logs
title=Killing Floor Server
set "_runStat="
set _servBat=KFserver
set _servLog=.\logs\%_servBat%.bat.log
set _gameLog=.\logs\%_servBat%.log
:: server command line
set _gameCmd=[COLOR=Red]ucc server kf-westlondon.rom?game=KFmod.KFGameType?VACSecured=true?MaxPlayers=6[/COLOR]
set _gameCmd=%_gameCmd% -log=%_gameLog%
echo ::
echo :: This batch will autorun %_servBat%.
echo :: -to restart %_servBat%, end the ucc server task.
echo :: -to shut down %_servBat%, ctrl-c or close this window.
echo ::
if exist ucc.exe (echo :: %_servBat% initializing...) else (echo :: ucc server not found! & echo :: This batch is to be run in the KF system directory. & goto:eof)
:: log server start/create batch log
echo ::
echo :: Output logged to %_servLog%
if exist %_servLog% (echo ::%_servBat% Start:: >>%_servLog%) else (md logs & echo ::%_servBat% Start:: >%_servLog%)
echo %_gameCmd% >>%_servLog%
:: start/restart server
:start
:: backup last server log
echo ::
echo :: Backup %_gameLog:.\logs\=%...
set _logTime=%_servBat%-%DATE:/=-%_%TIME:~0,2%.%TIME:~3,2%.log
set _logTime=%_logTime: =0%
if exist %_gameLog% (ren %_gameLog% %_logTime% & echo :: %_logTime% & echo :: Backup complete.) else (echo :: No log to backup.)
echo ::
:: log batch restart
if defined _runStat (echo :: Restart %_servBat%)
echo :: %date%
echo :: %time: =0%
echo ::
if defined _runStat (echo :Restart %_servBat%: >>%_servLog%)
if exist .\logs\%_logTime% (echo %_logTime% >>%_servLog%) else (echo No log to backup. >>%_servLog%)
echo %date% >>%_servLog%
echo %time: =0% >>%_servLog%
set "_logTime="
:: run the server
call %_gameCmd%
set _runStat=1
:: restart on exit/error
goto start
::
Last edited: