Files
ql-lg-server/scripts/watchdog.sh
T
esefandClaude Opus 5.5 bc5bd09c15 ql-lg-server: Quake Live LG vampiric practice server in Docker
One-command setup (SteamCMD + minqlx build), .env settings with a
listed/unlisted switch, three factories (lgvamp, lgvamp_nolag, lgvamp100),
warmup-text and welcome minqlx plugins, watchdog/backup/daily-restart,
docs for admins and players.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-08 01:39:43 +03:00

23 lines
936 B
Bash
Executable File

#!/bin/sh
# Hang watchdog (cron every 5 min). Docker already restarts the server when it crashes; this covers
# the other case: container "running" but the server not answering. Restarts it after 3 failed
# checks in a row (~15 min). Does nothing if the container was stopped on purpose.
# DRYRUN=1 logs without restarting; PORT=... overrides the port (testing).
. "$(dirname "$0")/env.sh"
STATE=logs/.watchdog-fails
LOG=logs/watchdog.log
PORT=${PORT:-$QPORT}
[ "$(docker inspect -f '{{.State.Status}}' "$NAME" 2>/dev/null)" = running ] || { rm -f $STATE; exit 0; }
if python3 tools/qlq.py 127.0.0.1 "$PORT" >/dev/null 2>&1; then
rm -f $STATE
else
n=$(( $(cat $STATE 2>/dev/null || echo 0) + 1 ))
echo $n > $STATE
echo "$(date '+%F %T') no answer ($n/3)" >> $LOG
if [ $n -ge 3 ]; then
echo "$(date '+%F %T') restarting $NAME" >> $LOG
[ -n "$DRYRUN" ] || docker restart "$NAME" >/dev/null 2>&1
rm -f $STATE
fi
fi