Skip to content

feat(stop): warn players in-game before stop, restart and update, and retry postponed updates - #5025

Merged
dgibbs64 merged 9 commits into
developfrom
feature/warnplayers
Oct 14, 2026
Merged

dgibbs64 merged 9 commits into
developfrom
feature/warnplayers

Conversation

@dgibbs64

@dgibbs64 dgibbs64 commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Description

Warns players in-game before LinuxGSM stops, restarts or updates a server, and makes updates that were postponed because players were online run automatically once the server is empty. Part of #674 (the console tier; telnet and RCON are not included).

Player warnings

## Player Warnings | https://docs.linuxgsm.com/features/player-warnings
# Minutes to warn players in-game before a stop, restart or update. 0 to disable.
# e.g. 15 warns at 15, 10, 5, 3 and 1 minutes.
warnplayerstimer="0"
  • Off by default. One number, in minutes. The steps are worked out from 60, 30, 15, 10, 5, 3, 1, keeping those below the timer: 15 warns at 15, 10, 5, 3, 1; 10 at 10, 5, 3, 1; 7 at 7, 5, 3, 1.
  • Message: Server stopping|restarting|updating in N minute(s), sent with the game's own chat command. The command for each game is set in fn_stop_warn_players_command (command_stop.sh), not in the config, as it is game data rather than a setting.
  • When: stop, restart, backup (with stoponbackup, "restarting"), update and workshop-update when they stop a running server. Never for monitor crash restarts, force-update or validate.
  • Skipped when the server is empty (gamedig query), and the countdown ends early if everyone leaves. If the player count can't be checked (query fails or querymode is not 2/3), it warns anyway.
  • Supported: servers with consoleinteract="yes" and a known chat command (78 servers). Others print Warning players: not supported by <game>: skipped.
  • Runs before the stopping lockfile is created, so a long countdown doesn't trip monitor's 5-minute stale-lock check. Monitor runs normally during a countdown.
  • CTRL+c during the countdown tells players Server <action> cancelled.
  • Two commands at once (e.g. a cron restart and an update): the second waits for the first countdown to finish, using a <selfname>-warning.lock holding the PID. A lock left by a dead process is removed.
  • The server status is checked every 10 seconds while waiting, so a server that crashes or is stopped mid-countdown is noticed straight away.
Chat command (%s = message) Servers
say %s All Source, Source 2 and GoldSrc servers; cod coduo cod2 cod4 codwaw mohaa rtcw wet etl jk2 q2 q3 q4 ql qw sof2 wf xnt; mc pmc mcb terraria unt hyt bt
servermsg "%s" pz
c_announce("%s") dst
/bc 10 %s scpsl scpslsm
/announce %s vints
alert %s wmc
%s fctr (plain console text is chat)

When players can't be counted

Counting players needs gamedig (optional, installed only when Node.js 16+ is present) and querymode 2 or 3. query_gsquery.py only reports whether the server responds, so it can't count players. check_players_online.sh now records why the count is unavailable (gamedig is not installed, jq is not installed, querymode N cannot count players, or query failed):

  • Warnings: the countdown runs in full, as it can't tell the server is empty, and says why once: Warning players: unable to check for players (gamedig is not installed): warning anyway.
  • stoponlyifnoplayers: the stop goes ahead as before, but now always says why: Unable to determine player count (querymode 4 cannot count players): stoponlyifnoplayers check skipped. Previously querymode 1, 4 and 5 skipped the check silently.

Postponed updates

With stoponlyifnoplayers="on", an update that finds an update while players are online is now postponed: it writes <selfname>-update-request.lock, and monitor runs the update once the server is empty (like the existing restart request). If players are still online, monitor logs update postponed and carries on monitoring.

  • Monitor starts the update in the background (setsid) and returns straight away. In the Docker images monitor is the healthcheck (every 60s, 60s timeout), so running the update inside monitor would have been killed part way through. The background update shows as update in the process list, so other monitor runs see it in progress.
  • A postponed force-update is remembered (force in the request) and retried with forceupdate=1, so it isn't turned into a plain update that finds nothing to do.

Bugs fixed along the way

  • stoponlyifnoplayers did not work for update, backup or workshop-update, and left the server down. These commands call command_stop.sh with exitbypass=1, so the core_exit.sh in fn_stop_players_online returned instead of exiting. The stop carried on, then command_stop.sh's own core_exit.sh ended the whole command: the server was stopped and not updated until monitor restarted it. Now a prevented stop exits the whole command (server keeps running). Note this changes backup with stoponbackup="on": while players are online it is now skipped instead of stopping the server.
  • A prevented stop left <selfname>-stopping.lock behind, because the player check ran after the lock was created. The check now runs before it.
  • A postponed update left last-updated.lock saying "updated but not restarted", so the retried update restarted the server instead of updating. It is now removed when the update is postponed.
  • CTRL+c did not exit while one command was running another (e.g. restart running stop, update running stop): core_trap.sh called core_exit.sh with exitbypass still set, so it returned and the command carried on. During a restart countdown this told players "cancelled" and then restarted anyway. The trap now clears exitbypass.
  • A skipped backup or update left its lockfiles behind. A leftover backup.lock makes the next backup within 60 minutes refuse to run ("Backup is currently running"), and last-updated.lock makes the next command restart the server. When a stop is prevented by players, or a countdown is cancelled, the calling command's backup.lock, update.lock and last-updated.lock are now removed (fn_stop_cancel_locks). command_backup.sh's own CTRL+c trap also tells players the countdown was cancelled.
  • Monitor could restart the server in the middle of an update. It deletes an update.lock older than 15 minutes without checking whether the update is still running. The non-SteamCMD updaters (Minecraft, Factorio, MTA and others) write update.lock before stopping the server, so a warning countdown plus download could pass 15 minutes, after which monitor removed the lock, found the server stopped and started it mid-update. A stale update.lock is now only removed when no update, force-update, validate or workshop-update is running.
  • A validate stopped by players left update.lock behind; it is now removed with the other locks.
  • 10 _default.cfg files had no ## Stop block (stoponlyifnoplayers): ac hyt jbep3 mcv pvr rsdw rwr sm tf2c xnt. Added.

Testing

Scenarios

Tested on a Minecraft server built from this branch. A gamedig stub controlled the player count (a number, or a failed query), and the chat lines were checked in Minecraft's own log ([Server] Server restarting in 3 minutes).

# Scenario Result
T01 warnplayerstimer="0" No warnings, immediate stop
T02 warnplayerstimer="abc" (also -5, 1.5, " 5" in the step test) must be a number of minutes: skipped, immediate stop
T03 Chat command lookup run for all 144 servers 78 get the command in the table above, the rest get none and skip
T04 consoleinteract="no" not supported by Minecraft: skipped
T05 Server empty no players on the server, immediate stop
T06 2 players, stop, timer 1 Server stopping in 1 minute, stopped after 64s
T07 2 players, restart, timer 3 restarting in 3 minutes, 1 minute, restarted after 188s
T08 Query fails Countdown runs (warns to be safe)
T09 querymode="1" Countdown runs
T10 stoponlyifnoplayers="on", players stop prevented, no warnings, no leftover stopping lock
T11 Players leave mid-countdown (timer 3) Stopped at the next check after 124s, one warning sent
F1 Full timer 15, restart 15, 10, 5, 3, 1 minutes at the right times, restarted after 909s
U1 Update found, players, stoponlyifnoplayers="on" Update postponed until the server is empty, server keeps running, not updated, request lock written, last-updated.lock removed
U2 Monitor, players still online update postponed, request kept, monitoring continues
U3 Monitor, server empty Update runs (1.20.1 to 26.3), request removed, server running
U4 Update found, players, stoponlyifnoplayers="off", timer 1 Server updating in 1 minute, then updated
U6 Request lock but no update available Monitor runs update, No update available, request removed
U7 stoponlyifnoplayersallcommands="off" Update ignores players, warns, updates
X1 forceupdate=1 (as set by force-update) No warnings, stopped in 3s
B1 Backup, stoponbackup="on", players Server restarting in 1 minute, then backup
B2 Backup, players, stoponlyifnoplayers="on" stop prevented, backup skipped, server keeps running, backup.lock removed
R1 Restart, players, stoponlyifnoplayers="on" Existing restart request unchanged; monitor restarts when empty, no warnings
C1 Monitor restarts a crashed server No warnings
K1 CTRL+c during a stop countdown (real terminal) Server stopping cancelled sent, locks removed, server keeps running
K2 CTRL+c with no countdown running No message sent
K3 CTRL+c during a restart countdown Server restarting cancelled, the restart is really cancelled (before the trap fix it restarted anyway), server keeps running
K4 CTRL+c during an update countdown Server updating cancelled, not updated, update.lock and last-updated.lock removed
K5 CTRL+c during a backup countdown (backup's own trap) Server restarting cancelled, backup cancelled, backup.lock removed, server keeps running
P1 Restart countdown running, then stop Stop waits, then runs its own countdown once the restart finishes
S1 Warning lock from a dead PID Removed, command continues
D1 Server killed mid-countdown Noticed within 20s, already stopped
M1 Monitor during a countdown Normal checks pass, no interference

Final regression

After the last fixes, the main scenarios above were run again in one pass (55 in total, all passing), plus:

# Scenario Result
DK1 Postponed update, server empty, monitor killed after 15s (as a Docker healthcheck timeout would) Monitor returned after 5s, the update finished in the background (1.20.1 to 26.3), server running, request removed
FU1 force-update postponed by players, then monitor with the server empty Request recorded as force; the background update ran forced (26.3 > 26.3, re-downloaded), server restarted
UL1 Update countdown running, update.lock aged to 20 minutes, monitor LinuxGSM is updating the game server, lock kept, update completed
V1 validate prevented by players update.lock removed, last-updated.lock kept

Without a player count

# Scenario Result
G1 No gamedig, warnplayerstimer="1", server empty unable to check for players (gamedig is not installed): warning anyway, full countdown
G2 No gamedig, stoponlyifnoplayers="on" Unable to determine player count (gamedig is not installed): stoponlyifnoplayers check skipped, server stopped
G3 No gamedig, update found, both settings on Both messages, warns, updates (no postponement)
G4 No gamedig, pending restart request, monitor Restart runs
Q1 querymode="4", warnplayerstimer="1" unable to check for players (querymode 4 cannot count players): warning anyway
Q2/Q3 querymode 4 and 1, stoponlyifnoplayers="on" Message shown (previously silent), server stopped
R1-R4 With gamedig: empty, query fails, players online Unchanged: skips when empty, (query failed) shown, players prevent the stop

Chat command delivery

Each chat command was sent to running test servers, exactly as the code sends it (tmux send-keys -l then ENTER):

Result Servers
Broadcast seen in the console cs hldm css gmod l4d2 cs2 nmrih (Source/GoldSrc say), qw wf xnt, fctr ([CHAT] <server>:), bt (HOST:), wmc ([Alert]), scpsl (BC#Global broadcast sent.), mc (test container)
Accepted (no error; an unknown command does error) cod2 codwaw wet q2 q3 ql sof2 (ioquake3 say only reaches connected clients), mcb, unt, dst
Accepted via echo marker test cod coduo cod4 rtcw etl jk2
No running test server, from documentation pz vints pmc hyt q4 terraria scpslsm

Two things found and fixed during delivery testing:

  • Clearing the console line first with C-u broke the ]-prompt consoles (cod cod4 rtcw etl jk2 silently dropped the command), so nothing is sent before the message.
  • SCP:SL needs /bc, not bc (Command bc does not exist!).

Known limitations

  • A warning sent while a game is still booting can be lost (seen when a countdown started seconds after a restart). Nobody can be connected at that point.
  • last-updated.lock is shared by instances in the same directory, so removing it on a postponed update could also clear another instance's pending "restart after update" (rare).
  • Not tested: workshop-update (same code path as update), and real gamedig player counts (the existing query_gamedig.sh parsing is unchanged).

Type of change

  • Bug fix (a change which fixes an issue).
  • New feature (a change which adds functionality).
  • New Server (new server added).
  • Refactor (restructures existing code).
  • Comment update (typo, spelling, explanation, examples, etc).

Checklist

  • This pull request links to an issue.
  • This pull request uses the develop branch as its base.
  • This pull request subject follows the Conventional Commits standard.
  • This code follows the style guidelines of this project.
  • I have performed a self-review of my code.
  • I have checked that this code is commented where required.
  • I have provided a detailed enough description of this PR.
  • I have checked if documentation needs updating.

Documentation

  • If this PR changes the documentation, please create a PR on the LinuxGSM-Docs repo.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 21:32
@dgibbs64 dgibbs64 added this to the v26.4.0 milestone Oct 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added type: feature New feature or request engine: lwjgl2 Issues related to lwjgl2 engine engine: terraria Issues related to terraria engine engine: unity3d Issues related to unity3d engine labels Oct 11, 2026
@github-actions github-actions Bot added engine: iw3.0 Issues related to iw3.0 engine engine: idtech3 Issues related to idtech3 engine engine: source engine: vintagestory Issues related to vintagestory engine engine: iw2.0 Issues related to iw2.0 engine engine: factorio Issues related to factorio engine engine: goldsrc engine: unreal5 Issues related to unreal5 engine engine: ioquake3 Issues related to ioquake3 engine engine: source2 Issues related to source2 engine engine: dontstarve Issues related to dontstarve engine engine: hytale Issues related to hytale engine engine: bedrock Issues related to bedrock engine engine: unreal3 Issues related to unreal3 engine game: Minecraft Issues related to Minecraft game: Terraria Issues related to Terraria game: SCP: Secret Laboratory ServerMod Issues related to SCP: Secret Laboratory ServerMod game: Call of Duty: World at War Issues related to Call of Duty: World at War game: Call of Duty: United Offensive Issues related to Call of Duty: United Offensive game: Jabroni Brawl: Episode 3 Issues related to Jabroni Brawl: Episode 3 labels Oct 11, 2026
@github-actions github-actions Bot added game: Counter-Strike: Source Issues related to Counter-Strike: Source game: Don't Starve Together Issues related to Don't Starve Together game: ET: Legacy Issues related to ET: Legacy game: Hytale Issues related to Hytale game: Jedi Knight II: Jedi Outcast Issues related to Jedi Knight II: Jedi Outcast game: Minecraft Bedrock Issues related to Minecraft Bedrock game: Military Conflict: Vietnam Issues related to Military Conflict: Vietnam game: PaperMC Issues related to PaperMC game: Pavlov VR Issues related to Pavlov VR game: Unturned Issues related to Unturned game: Wolfenstein: Enemy Territory Issues related to Wolfenstein: Enemy Territory game: WaterfallMC Issues related to WaterfallMC game: Xonotic Issues related to Xonotic labels Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine: bedrock Issues related to bedrock engine engine: dontstarve Issues related to dontstarve engine engine: factorio Issues related to factorio engine engine: goldsrc engine: hytale Issues related to hytale engine engine: idtech3 Issues related to idtech3 engine engine: ioquake3 Issues related to ioquake3 engine engine: iw2.0 Issues related to iw2.0 engine engine: iw3.0 Issues related to iw3.0 engine engine: lwjgl2 Issues related to lwjgl2 engine engine: source engine: source2 Issues related to source2 engine engine: terraria Issues related to terraria engine engine: unity3d Issues related to unity3d engine engine: unreal3 Issues related to unreal3 engine engine: unreal5 Issues related to unreal5 engine engine: vintagestory Issues related to vintagestory engine game: Call of Duty: United Offensive Issues related to Call of Duty: United Offensive game: Call of Duty: World at War Issues related to Call of Duty: World at War game: Call of Duty Issues related to Call of Duty game: Call of Duty 2 Issues related to Call of Duty 2 game: Call of Duty 4 Issues related to Call of Duty 4 game: Counter-Strike: Source Issues related to Counter-Strike: Source game: Counter-Strike 2 Issues related to Counter-Strike 2 game: Don't Starve Together Issues related to Don't Starve Together game: ET: Legacy Issues related to ET: Legacy game: Factorio Issues related to Factorio game: Garrys Mod Issues related to Garrys Mod game: Half-Life: Deathmatch Issues related to Half-Life: Deathmatch game: Hytale Issues related to Hytale game: Jabroni Brawl: Episode 3 Issues related to Jabroni Brawl: Episode 3 game: Jedi Knight II: Jedi Outcast Issues related to Jedi Knight II: Jedi Outcast game: Left 4 Dead 2 Issues related to Left 4 Dead 2 game: Medal of Honor: Allied Assault Issues related to Medal of Honor: Allied Assault game: Military Conflict: Vietnam Issues related to Military Conflict: Vietnam game: Minecraft Bedrock Issues related to Minecraft Bedrock game: Minecraft Issues related to Minecraft game: No More Room in Hell Issues related to No More Room in Hell game: PaperMC Issues related to PaperMC game: Pavlov VR Issues related to Pavlov VR game: Return to Castle Wolfenstein Issues related to Return to Castle Wolfenstein game: RuneScape: Dragonwilds Issues related to RuneScape: Dragonwilds game: SCP: Secret Laboratory ServerMod Issues related to SCP: Secret Laboratory ServerMod game: SCP: Secret Laboratory Issues related to SCP: Secret Laboratory game: Soldier Of Fortune 2: Gold Edition Issues related to Soldier Of Fortune 2: Gold Edition game: Team Fortress 2 Classified Issues related to Team Fortress 2 Classified game: Terraria Issues related to Terraria game: Unturned Issues related to Unturned game: Vintage Story Issues related to Vintage Story game: WaterfallMC Issues related to WaterfallMC game: Wolfenstein: Enemy Territory Issues related to Wolfenstein: Enemy Territory game: Xonotic Issues related to Xonotic type: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sdtdserver] Feature request: announce server restarts ingame via telnet

2 participants