Forráskód Böngészése

fix(logs): rotate the game log on start for all servers that set one (#5135)

Game log rotation on start only ran for unreal2, so servers that write a
single fixed game log (rust, ck, hw, ut3, cmw) overwrote the previous
run's log on every start or restart.

Rotate whenever the server config defines gamelogdate and the game log
file exists. Servers without gamelogdate, or whose games write their own
dated logs, are unchanged.

Log cleanup only pruned game logs for unreal2 and source. Other servers
now prune their rotated <selfname>-game-*.log files older than logdays.
The prune is limited to that name pattern at the top level of gamelogdir,
since some servers set gamelogdir to a game directory (stn uses
serverfiles).

Fixes #4751
Daniel Gibbs 2 napja
szülő
commit
5e10a81589
2 módosított fájl, 6 hozzáadás és 1 törlés
  1. 1 1
      lgsm/modules/command_start.sh
  2. 5 0
      lgsm/modules/core_logs.sh

+ 1 - 1
lgsm/modules/command_start.sh

@@ -102,7 +102,7 @@ fn_start_tmux() {
 
 	# Log rotation.
 	fn_script_log_info "Rotating log files"
-	if [ "${engine}" == "unreal2" ] && [ -f "${gamelog}" ]; then
+	if [ -n "${gamelogdate}" ] && [ -f "${gamelog}" ]; then
 		mv "${gamelog}" "${gamelogdate}"
 	fi
 	if [ -f "${lgsmlog}" ]; then

+ 5 - 0
lgsm/modules/core_logs.sh

@@ -58,6 +58,11 @@ if [ "$(find "${lgsmlogdir}"/ -type f -mtime +"${logdays}" | wc -l)" -ne "0" ];
 		find "${gamelogdir}"/ -type f -mtime +"${logdays}" | tee >> "${lgsmlog}"
 		gamecount=$(find "${gamelogdir}"/ -type f -mtime +"${logdays}" | wc -l)
 		find "${gamelogdir}"/ -mtime +"${logdays}" -type f -exec rm -f {} \;
+	# Rotated game logfiles.
+	elif [ -n "${gamelogdate}" ] && [ -d "${gamelogdir}" ]; then
+		find "${gamelogdir}"/ -maxdepth 1 -type f -name "${selfname}-game-*.log" -mtime +"${logdays}" | tee >> "${lgsmlog}"
+		gamecount=$(find "${gamelogdir}"/ -maxdepth 1 -type f -name "${selfname}-game-*.log" -mtime +"${logdays}" | wc -l)
+		find "${gamelogdir}"/ -maxdepth 1 -type f -name "${selfname}-game-*.log" -mtime +"${logdays}" -exec rm -f {} \;
 	fi
 	# Console logfiles.
 	if [ "${consolelog}" ]; then