Files
hnefatafl/deploy/hnefatafl-pulse.sh
T
Eric WagonerandClaude Opus 5.5 010f99aa9c Hnefatafl moves to the shared hall host
The new kit setup, its own Caddy site file and access log, and the
host's address everywhere. The old droplet forwards to hall until the
A record moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
2026-09-25 16:56:33 -04:00

37 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# The operations pulse, printed ON the droplet: the game server's health,
# errors in its journal, the last week of the rollup, the backup's last word,
# and the box's vitals. Read by the hnefatafl-pulse skill.
set -u
echo "as of $(date -u '+%F %H:%M') UTC on $(hostname); up $(uptime -p | sed 's/up //')"
echo "--- game server"
systemctl is-active hnefatafl >/dev/null && echo "hnefatafl: active since $(systemctl show hnefatafl -p ActiveEnterTimestamp --value)" || echo "hnefatafl: NOT ACTIVE"
systemctl is-active caddy >/dev/null && echo "caddy: active" || echo "caddy: NOT ACTIVE"
echo "restarts in 7 days: $(journalctl -u hnefatafl --since '7 days ago' -o cat | grep -c 'Started hnefatafl')"
ERR=$(journalctl -u hnefatafl --since '7 days ago' -p err -o cat | grep -vc '^$')
echo "journal errors in 7 days: $ERR"
journalctl -u hnefatafl --since '7 days ago' -o cat | grep -iE "error|unhandled|exception" | tail -3 | sed 's/^/ /'
echo "--- rollup, last 7 days (people / requests / rooms opened / turns)"
if [ -s /var/lib/hnefatafl/rollup.jsonl ]; then
tail -7 /var/lib/hnefatafl/rollup.jsonl | python3 -c '
import json, sys
for l in sys.stdin:
r = json.loads(l); rm = r["rooms"]
print(" %s %3d people %4d requests %2d rooms (%d started, %d with turns) %3d turns bots %d addr refs %s" % (
r["day"], r["humanAddresses"], r["human"], rm["created"], rm["started"], rm["withTurns"], r["turns"], r["botAddresses"],
",".join(sorted(r["referrers"])) or "-"))'
else
echo " (no rollup yet)"
fi
echo "--- ledgers"
echo "rooms on disk: $(ls /var/lib/hnefatafl/rooms/*.jsonl 2>/dev/null | wc -l); touched in 24h: $(find /var/lib/hnefatafl/rooms -name '*.jsonl' -mmin -1440 2>/dev/null | wc -l); size $(du -sh /var/lib/hnefatafl/rooms 2>/dev/null | cut -f1)"
echo "--- backup"
if [ -f /var/log/hnefatafl/backup.log ]; then
grep -E "backup (start|done)|skipped|error|ERROR" /var/log/hnefatafl/backup.log | tail -2 | sed 's/^/ /'
else
echo " never run"
fi
echo "--- box"
echo "disk: $(df -h / | awk 'NR==2{print $5" used of "$2}'); memory: $(free -m | awk 'NR==2{print $7" MB available of "$2}'); load: $(cut -d' ' -f1-3 /proc/loadavg)"
echo "caddy access log: $(du -sh /var/lib/caddy/hnefatafl-access.log 2>/dev/null | cut -f1) live, $(ls /var/lib/caddy/hnefatafl-access*.log* 2>/dev/null | wc -l) files"