Repository navigation
[Bug]: monitor does not detect start and stop run with the st and sp short aliases #4999
Description
Severity
severity: medium
Reproducibility
reproducible: always
Regression
regression: no
Affects latest release
latest-release: yes
User story
As a game server administrator, I want monitor to leave my server alone while I start or stop it with ./gameserver st or ./gameserver sp, so that it does not restart a server that I am starting or stopping.
Script name
Any (e.g. vhserver)
Game
Any (not game specific)
Linux distro
Other
Command
command: monitor, command: start, command: stop
Expected behavior
While ./gameserver st is running and lock/${selfname}-starting.lock exists, monitor prints Checking start: LinuxGSM is starting and exits, as it already does for ./gameserver start.
While ./gameserver sp is running and lock/${selfname}-stopping.lock exists, monitor prints Checking stop: LinuxGSM is stopping and exits, as it already does for ./gameserver stop.
./gameserver s is the sponsor command. It does not start or stop anything, so it should not make monitor exit.
Actual behavior
Monitor does not detect st or sp and goes on to the session and query checks.
sp: the stop command removes${selfname}-monitoring.lockonly after the server has shut down, so monitor keeps running during the graceful shutdown. The session or query check fails on the server that is going down, monitor sends amonitor-sessionormonitor-queryalert and runscommand_restart.sh. The server can end up running again after the user stopped it.st: after a crash${selfname}-monitoring.lockis still present. If monitor runs while./gameserver stbrings the server back, it can reportChecking session: FAIL, send amonitor-sessionalert and runcommand_restart.shnext to the user's start.s(sponsor): while a starting or stopping lockfile younger than 5 minutes exists, monitor reportsLinuxGSM is starting/LinuxGSM is stoppingand skips the run.
Further information
core_getopt.sh defines the aliases as:
cmd_start=("st;start" "command_start.sh" "Start the server.")
cmd_stop=("sp;stop" "command_stop.sh" "Stop the server.")
cmd_sponsor=("s;sponsor" "command_sponsor.sh" "Sponsorship options.")fn_monitor_check_starting (line 79) and fn_monitor_check_stopping (line 102) in lgsm/modules/command_monitor.sh only make monitor exit when the lockfile exists and pgrep -fcx finds a matching process. Next to start and stop both check for /bin/bash ./${selfname} s, which is the sponsor alias, not st or sp.
The checks were added in 4ddd8ee (#4296) as pgrep -fc "${selfname} s". Without -x that pattern matched every command starting with s, including st and sp. 8cd16ac ("fix: make pgrep unique") switched to exact matching with pgrep -fcx "/bin/bash ./${selfname} s", after which only the sponsor command matches. Both commits shipped in v23.5.0, so no release has detected st or sp.
Suggested fix: check for st instead of s on line 79 and for sp instead of s on line 102. I will open a PR for it.
Pre-checks
- I ran update and validate before reporting this issue.
Found by reading the code on the current develop branch (28b1d67) and reproduced with the module functions themselves, see the steps and output below.
Relevant log output
# fn_monitor_check_starting / fn_monitor_check_stopping from develop (28b1d67d),
# lockfile present, while "/bin/bash ./testserver <command>" is running:
lockfile command result
starting start SKIP (start detected)
starting st CONTINUE (monitor proceeds) <-- bug
starting s SKIP (start detected) <-- sponsor, false positive
stopping stop SKIP (stop detected)
stopping sp CONTINUE (monitor proceeds) <-- bug
stopping s SKIP (stop detected) <-- sponsor, false positiveSteps to reproduce
- Install any game server (e.g.
vhserver) and start it with./vhserver start, so the monitoring lockfile exists. - Run
./vhserver sp. - While the server is shutting down gracefully, run
./vhserver monitor(or let the monitor cron job run). - Monitor does not print
Checking stop: LinuxGSM is stopping. It goes on to the session and query checks, and when they fail it sends an alert and restarts the server. - Repeat with
./vhserver stop: monitor printsChecking stop: LinuxGSM is stoppingand exits.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields✅ Done
Activity
fix(monitor): detect update, start and stop run with their short alia…
Release v26.3.0 (#5005)
dgibbs64 commentedon Oct 10, 2026
Fixed by #5002 on
develop. It ships in v26.3.0.Release v26.3.0 (#5007)