Skip to content

fix(monitor): detect start and stop run with the st and sp short aliases - #5000

Closed
borzaka wants to merge 1 commit into
GameServerManagers:developfrom
borzaka:fix/monitor-start-stop-short-alias
Closed

borzaka wants to merge 1 commit into
GameServerManagers:developfrom
borzaka:fix/monitor-start-stop-short-alias

Conversation

@borzaka

@borzaka borzaka commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Description

fn_monitor_check_starting and fn_monitor_check_stopping in lgsm/modules/command_monitor.sh make monitor exit when ${selfname}-starting.lock or ${selfname}-stopping.lock exists and a start or stop process is running. They find that process with pgrep -fcx against start / stop and s. But s is the sponsor alias. core_getopt.sh defines the start and stop commands as cmd_start=("st;start" ...) and cmd_stop=("sp;stop" ...).

Because pgrep -x needs an exact match:

  • ./gameserver st and ./gameserver sp are not detected. During sp the monitoring lockfile stays until the server has shut down, so monitor goes on to the session and query checks, fails them on the server that is going down, sends an alert and runs command_restart.sh. The same can happen while st brings a crashed server back.
  • ./gameserver s (sponsor) makes monitor skip its run while a starting or stopping lockfile younger than 5 minutes exists.

s used to work as a prefix before 8cd16ac switched these checks to exact matching. This PR checks for st instead of s in fn_monitor_check_starting and for sp instead of s in fn_monitor_check_stopping. Only lgsm/modules/command_monitor.sh is changed.

Fixes #4999

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).

Testing

Please list the exact validation you performed and the outcome.

  • Commands/tests run:

    • Extracted fn_monitor_check_starting and fn_monitor_check_stopping from both develop (28b1d67) and this branch, stubbed the print/log helpers and core_exit.sh, and ran them with the matching lockfile present while a real /bin/bash ./testserver <command> process was running.
    • Ran the same checks with no matching process, and with the lockfile missing.
    • Checked for false positives with /bin/bash ./testserver <command> running for sponsor, sd, sk, the other of start/stop, and st extra / sp extra.
    • bash -n lgsm/modules/command_monitor.sh and shellcheck 0.11.0 with the repository's .shellcheckrc.
    • Not run: a full start/stop and monitor cycle on an installed game server.
  • Result:

    Lockfile Running command develop This branch
    starting start skip (start detected) skip (start detected)
    starting st monitor continues skip (start detected)
    starting s (sponsor) skip (start detected) monitor continues
    starting sponsor, sp, stop, sd, sk, st extra monitor continues monitor continues
    stopping stop skip (stop detected) skip (stop detected)
    stopping sp monitor continues skip (stop detected)
    stopping s (sponsor) skip (stop detected) monitor continues
    stopping sponsor, st, start, sd, sk, sp extra monitor continues monitor continues
    starting / stopping, no process – monitor continues monitor continues
    none st / sp monitor continues monitor continues

    No bash -n or shellcheck findings.

  • Environment used (distro/version): Ubuntu 22.04.5 LTS, bash 5.1.16, procps-ng 3.3.17.

Risk and rollback

  • Risk level: low. Two exact-match pgrep patterns change from s to st / sp; the lockfile checks, the stale lockfile handling and the other monitor checks are unchanged.
  • Rollback plan: revert this commit.

Breaking changes

  • No breaking changes.
  • Breaking changes included (describe below).

Documentation impact

  • No documentation update required.
  • User documentation update required.
  • Developer documentation update required.

Checklist

PR will not be merged until all steps are complete.

  • 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 provided a detailed enough description of this PR.

Documentation

If documentation does need updating either update it by creating a PR (preferred) or request a documentation update.

Thank you for your Pull Request!

🤖 Generated with Claude Code

fn_monitor_check_starting and fn_monitor_check_stopping exit monitor
when the starting or stopping lockfile exists and a start or stop
process is running. Besides the long commands they checked for "s",
which is the sponsor alias, not the "st" and "sp" aliases of start and
stop. Since pgrep matches exactly, "./gameserver st" and
"./gameserver sp" were not detected and monitor could restart a server
that was being started or stopped, while "./gameserver s" made monitor
skip its run.

Fixes GameServerManagers#4999

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@borzaka

borzaka commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

I have the 5000th PR! 🥳

@dgibbs64

Copy link
Copy Markdown
Member

Thanks @borzaka, and sorry: #5002 merged the identical change after you'd opened this, which I should have checked first. Closing it as covered by #5002. You'll be credited in the v26.3.0 release notes. (And congratulations on PR #5000!)

@dgibbs64 dgibbs64 closed this Oct 10, 2026
@borzaka

borzaka commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

No problem, and thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants