The HEALTHCHECK LinuxGSM "monitor" command restarts game server in a loop when server shuts down cleanly...

Open
#127 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
48/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
docker, shell
Domain
devops

Research direction

Read entrypoint-healthcheck.sh and the Dockerfile HEALTHCHECK reference first. Make the health monitor skip its check when /tmp/disable-monitor exists without exiting 0 or 1, while retaining normal monitoring otherwise; done means a cleanly stopped game server is not restarted until the container is restarted.

Written by the indexing model from the issue text.

Description

enhancement
  • Many games have mods that let an admin trigger a shutdown such as "15 minutes until shutdown. Please log out...".
  • After 15 minutes, the game itself shuts off the server.
  • But because LinuxGSM's docker images have a HEALTHCHECK line that runs the monitor command endlessly every minute, it will detect that the server has shut down and will start itself again.
  • Therefore LinuxGSM prevents the game from shutting itself down and interrupts a common scenario (servers that shut themselves down with a timer/warning).

This is only fixable by improving the containers to have a /tmp killswitch for the health monitor externally. Like this:

  • Dockerfile example:
HEALTHCHECK CMD [ "/bin/sh", "-c", "[ -f /tmp/disable-monitor ] || curl -f http://localhost/health" ]
  • How to kill such a healthcheck monitor externally:
podman exec sdtdserver touch /tmp/disable-monitor

And because it's in /tmp it will vanish when the container starts up the next time.


In LinuxGSM's case, that type of logic would have to be added to this file instead:

https://github.com/GameServerManagers/docker-linuxgsm/blob/main/entrypoint-healthcheck.sh

Basically adapt that file to not do a "monitor" check if /tmp/disable-monitor exists.

Do NOT exit 0 (or exit 1) if that file exists. Simply skip the health check. Because otherwise, the "disabled" healthcheck itself would trigger an instant container shutdown every minute, which is not correct.

Instead, simply skip it, perhaps echoing a log message saying that health monitor is disabled and being skipped.

After that, the server will simply sit in a shutdown state and the health check will do nothing. The server admin then "simply" has to stop the container itself after that state has been reached.


If LinuxGSM supports a feature like this, I would then be able to just add that command to the same script that sends the "15 minute shutdown" command to the server itself. Then the game would take care of shutting down, and the monitor would not restart the game anymore. After the server itself has shut itself down, I would just have to manually stop the container as usual.

Next time I start the container again, the health check would be running as usual again (since /tmp is a tmpfs and isn't preserved).

This is the solution.

Dominant language
Shell
Stars
347
Forks
26
Avg merge
8h 2m
Merged PRs (30d)
2

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from GameServerManagers/docker-gameserver

All issues in GameServerManagers/docker-gameserver

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.