N7: Dedicated server packaging, health endpoint and graceful shutdown
- packaging/server/tidewall-server: a wrapper that turns SIGTERM and SIGINT into a clean stop through the server's new --stop-file, since the engine can't catch signals. The server tells everyone it shut down, logs its statistics and exits 0; the wrapper kills it only after 15 s. - --config=PATH reads options from a file (packaging/server/server.cfg); options after it on the command line win. - --health-port answers GET /health with JSON (phase, players, tick, uptime) on loopback by default. HealthServer is non-blocking and bounded. - packaging/docker: a debian:13 image that checks the engine against tools/engine.sha512, imports the game at build time, runs as an unprivileged user, and works with a read-only root and a small /tmp. compose.yaml is project and container tidewall-server, read-only, no capabilities. - packaging/systemd: a hardened unit with a dynamic user. - make server-package-check: compose up, healthy, non-root, read-only, a real headless client joins over UDP into the drop, then SIGTERM stops it cleanly. This also covers H7 (graceful shutdown on SIGTERM). Closes #38 Closes #70 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# A Tidewall dedicated server as a systemd service. It expects the layout the Docker
|
||||
# image uses: the engine at /opt/tidewall/engine/godot, the imported game in
|
||||
# /opt/tidewall/game, the wrapper at /usr/local/bin/tidewall-server and the
|
||||
# configuration in /etc/tidewall/server.cfg. Then:
|
||||
#
|
||||
# sudo cp tidewall-server.service /etc/systemd/system/
|
||||
# sudo systemctl daemon-reload && sudo systemctl enable --now tidewall-server
|
||||
# journalctl -u tidewall-server -f
|
||||
#
|
||||
# systemctl stop sends SIGTERM to the wrapper, which asks the server to stop cleanly.
|
||||
[Unit]
|
||||
Description=Tidewall dedicated server
|
||||
Documentation=https://gitea.eom.dev/claude/tidewall
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/tidewall-server --config=/etc/tidewall/server.cfg
|
||||
# Only the wrapper gets SIGTERM; it passes the request on and waits.
|
||||
KillMode=mixed
|
||||
KillSignal=SIGTERM
|
||||
TimeoutStopSec=20
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
DynamicUser=yes
|
||||
RuntimeDirectory=tidewall-server
|
||||
Environment=TIDEWALL_STATE=%t/tidewall-server
|
||||
ProtectSystem=strict
|
||||
ProtectHome=yes
|
||||
PrivateTmp=yes
|
||||
PrivateDevices=yes
|
||||
NoNewPrivileges=yes
|
||||
ProtectKernelTunables=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectControlGroups=yes
|
||||
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
|
||||
RestrictNamespaces=yes
|
||||
LockPersonality=yes
|
||||
CapabilityBoundingSet=
|
||||
SystemCallArchitectures=native
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user