Skip to content

[Bug]: monitor does not detect start and stop run with the st and sp short aliases #4999

Closed

Description

@borzaka

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.lock only 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 a monitor-session or monitor-query alert and runs command_restart.sh. The server can end up running again after the user stopped it.
  • st: after a crash ${selfname}-monitoring.lock is still present. If monitor runs while ./gameserver st brings the server back, it can report Checking session: FAIL, send a monitor-session alert and run command_restart.sh next to the user's start.
  • s (sponsor): while a starting or stopping lockfile younger than 5 minutes exists, monitor reports LinuxGSM is starting / LinuxGSM is stopping and 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 positive

Steps to reproduce

  1. Install any game server (e.g. vhserver) and start it with ./vhserver start, so the monitoring lockfile exists.
  2. Run ./vhserver sp.
  3. While the server is shutting down gracefully, run ./vhserver monitor (or let the monitor cron job run).
  4. 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.
  5. Repeat with ./vhserver stop: monitor prints Checking stop: LinuxGSM is stopping and exits.

🤖 Generated with Claude Code

Activity

  1. added this to the v26.3.0 milestone on Oct 10, 2026
  2. dgibbs64 commented on Oct 10, 2026

    @dgibbs64
    Member

    Fixed by #5002 on develop. It ships in v26.3.0.

  3. added a commit that references this issue on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions