Browse Source

fix(stop): clear stale restart-request lock + warn on failed player query

Addresses Copilot review feedback on #4595:
- command_restart.sh: clear the *-restart-request.lock once a restart
  actually proceeds. Previously the lock was only written when postponing
  and never removed, so every subsequent monitor run would see the stale
  lock and trigger a repeat restart indefinitely. Fixed and verified against
  a live server: postponed restart -> monitor executes it and clears the
  lock -> a second monitor run no longer restarts.
- check_players_online.sh: if the gamedig query fails for every configured
  IP (e.g. gamedig/jq missing), playersonline now still fails open (so a
  broken query can't permanently block stop/restart) but prints a clear
  warning that the safety check could not run, instead of silently
  behaving as if the server were empty.
pull/4595/head
Daniel Gibbs 2 days ago
parent
commit
ec0efe72d8
Failed to extract signature
  1. 9
      lgsm/modules/check_players_online.sh
  2. 3
      lgsm/modules/command_restart.sh

9
lgsm/modules/check_players_online.sh

@ -12,14 +12,23 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
playersonline=""
if [ "${stoponlyifnoplayers}" == "on" ]; then
if [ "${querymode}" == "2" ] || [ "${querymode}" == "3" ]; then
querysucceeded="0"
for queryip in "${queryips[@]}"; do
query_gamedig.sh
if [ "${querystatus}" == "0" ]; then
querysucceeded="1"
if [ -n "${gdplayers}" ] && [ "${gdplayers}" -ne 0 ]; then
playersonline="${gdplayers}"
break
fi
fi
done
# The query failed for every configured IP, so the player count could not be
# determined. Fail open (proceed as if empty) rather than block the server
# indefinitely, but warn clearly since the safety check did not actually run.
if [ "${querysucceeded}" == "0" ]; then
fn_print_warn_nl "Unable to determine player count: stoponlyifnoplayers check skipped"
fn_script_log_warn "Unable to determine player count via gamedig: stoponlyifnoplayers check skipped"
fi
fi
fi

3
lgsm/modules/command_restart.sh

@ -20,6 +20,9 @@ if [ -n "${playersonline}" ]; then
date '+%s' > "${lockdir:?}/${selfname}-restart-request.lock"
core_exit.sh
fi
# Clear any pending restart request now that the restart is actually proceeding,
# so a stale lock doesn't trigger a repeat restart on the next monitor run.
rm -f "${lockdir:?}/${selfname}-restart-request.lock"
exitbypass=1
command_stop.sh
command_start.sh

Loading…
Cancel
Save