ソースを参照

fix(monitor): recheck backup and update before restarting the server (#5057)

Monitor checks for a running backup or update once near the start, but
the query loop can then take about 155 s of wall time because gamedig
timeouts are not counted towards the 60 s limit. A backup that starts in
that window stops the server, the query fails, and monitor's restart
brings the server back up while the backup is still archiving the files.

Run the backup and update checks again right before every monitor
triggered restart, in the query fail path and in the session checks, so
monitor exits instead of restarting when a backup or update now holds
its lock. This narrows the race from minutes to milliseconds; a full
lock between commands is tracked separately.
Daniel Gibbs 2 日 前
親
コミット
629c317858
1 ファイル変更、10 行追加、0 行削除
  1. 10 0
      lgsm/modules/command_monitor.sh

+ 10 - 0
lgsm/modules/command_monitor.sh

@@ -245,6 +245,11 @@ fn_monitor_check_update() {
 	fi
 }
 
+fn_monitor_check_backup_update() {
+	fn_monitor_check_backup
+	fn_monitor_check_update
+}
+
 # Source engine games may display a messages to indicate the server needs restarting.
 fn_monitor_check_update_source() {
 	if [ -f "${consolelogdir}/${selfname}-console.log" ] && [ "${engine}" == "source" ]; then
@@ -278,6 +283,7 @@ fn_monitor_check_session() {
 		fn_script_log_error "Checking session: There are PIDS with identical tmux sessions running"
 		fn_script_log_error "Checking session: Killing all tmux sessions with the socketname name ${socketname} and session name ${sessionname}"
 		pkill -f "tmux -L ${socketname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}"
+		fn_monitor_check_backup_update
 		command_restart.sh
 		core_exit.sh
 	# Check for tmux pids with the same tmux session and socket names. This will reduce issues with migration to release v23.5.0. #4296
@@ -288,6 +294,7 @@ fn_monitor_check_session() {
 		fn_script_log_error "Checking session: PIDS with the same tmux session and socket names are running"
 		fn_script_log_error "Checking session: Killing session with the socketname name ${sessionname} and session name ${sessionname}"
 		pkill -f "^tmux -L ${sessionname} new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}( |$)"
+		fn_monitor_check_backup_update
 		command_restart.sh
 		core_exit.sh
 	# Check for tmux pids that are using the old type of tmux session. This will reduce issues with migration to release v23.5.0. #4296
@@ -298,6 +305,7 @@ fn_monitor_check_session() {
 		fn_script_log_error "Checking session: PIDS with old type tmux session are running"
 		fn_script_log_error "Checking session: Killing session with the session name ${sessionname}"
 		pkill -f "^tmux new-session -d -x ${sessionwidth} -y ${sessionheight} -s ${sessionname}( |$)"
+		fn_monitor_check_backup_update
 		command_restart.sh
 		core_exit.sh
 	elif [ "${status}" != "0" ]; then
@@ -312,6 +320,7 @@ fn_monitor_check_session() {
 		fn_print_error "Checking session"
 		fn_print_fail_eol_nl
 		fn_script_log_fail "Checking session: FAIL"
+		fn_monitor_check_backup_update
 		alert="monitor-session"
 		alert.sh
 		fn_script_log_info "Checking session: Monitor is restarting ${selfname}"
@@ -423,6 +432,7 @@ fn_monitor_query() {
 					fn_print_fail "Querying port: ${querymethod}: ${queryip}:${queryport} : ${totalseconds}/${queryattempt}"
 					fn_print_fail_eol_nl
 					fn_script_log_warn "Querying port: ${querymethod}: ${queryip}:${queryport} : ${queryattempt} : FAIL"
+					fn_monitor_check_backup_update
 					# Send alert if enabled.
 					alert="monitor-query"
 					alert.sh