Skip to content

added features: implement graceful shutdown, tmux wrapper, and healthcheck#187

Open
tahmid-H wants to merge 1 commit into
ryansheehan:masterfrom
tahmid-H:feature/graceful-shutdown-tmux
Open

added features: implement graceful shutdown, tmux wrapper, and healthcheck#187
tahmid-H wants to merge 1 commit into
ryansheehan:masterfrom
tahmid-H:feature/graceful-shutdown-tmux

Conversation

@tahmid-H
Copy link
Copy Markdown

@tahmid-H tahmid-H commented Feb 6, 2026

Desription

Problems I encountered and tried to solve:

  1. World Save Doesn't Occur On Stop: Currently, docker stop or docker compose down etc kills the container immediately without saving the world.
  2. Server Kills On Ctrl+C: Attaching the container and pressing Ctrl+C also kills the container immediately without saving the world.

These issues mainly stemmed from trying to update the server, since I had to manually save and exit before updating, instead of a simple docker compose down && docker compose up -d.

Changes Made

  1. Tmux Wrapper: Server runs inside a detached tmux session instead of directly in the foreground. This allows container to run in background while having interactive console access via docker exec -it <container> tmux attach. Ctrl+C in the console now just detaches the console instead of abruptly shutting down the server.
  2. Graceful Shutdown: Added a trap for SIGTERM in bootstrap.sh. So commands such as docker stop or docker compose down now injects the exit command into the tmux session before shutting down the container/game server.
  3. Watchdog: Necessary with tmux addition. Added watchdog loop to monitor tmux session., so if the server crashes or stops, the tmux session dies and the container exits.
  4. Added Healthcheck to Dockerfile: Verifies server session by checking if tmux session is alive, since tmux session dies if the game server crashes.

This works best with a liberal stop_grace_period (I have it set to 1m but I'd say 2m just to be safe depending on the machine) if using docker compose, or adding -t -1 to docker down/stop/restart.

Let me know if you have any questions!

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.

1 participant