xonecas.ioDon't click! Sean Caetano Martin Sign in
tiny-adventure / docs / deploy.md 43 lines1.8 kB RenderedSource Raw

Deploy

The game runs as a systemd user service behind Caddy. The Go server serves the page, the API and the share cards on 127.0.0.1:8083. Caddy terminates TLS and proxies to it. Games and feedback live in ~/.local/state/tiny-adventure.

First install

  1. Clone the repo to ~/repos/tiny-adventure and build the server:

    git clone ~/repos/tiny-adventure cd ~/repos/tiny-adventure go build -o bin/server ./cmd/server mkdir -p ~/.local/state/tiny-adventure

  2. Install and start the user unit. Enable linger for the user so it runs without a login:

    install -Dm 644 deploy/tiny-adventure.service ~/.config/systemd/user/tiny-adventure.service systemctl --user daemon-reload systemctl --user enable --now tiny-adventure curl -s 127.0.0.1:8083/api/state | head -c 80

  3. Append the block in deploy/Caddyfile to the live Caddyfile, validate it and reload Caddy:

    cat /etc/caddy/Caddyfile deploy/Caddyfile > /tmp/Caddyfile caddy validate --adapter caddyfile --config /tmp/Caddyfile sudo install -m 644 /tmp/Caddyfile /etc/caddy/Caddyfile sudo systemctl reload caddy

Update

cd ~/repos/tiny-adventure
git pull
go build -o bin/server ./cmd/server
systemctl --user restart tiny-adventure

A restart keeps every game. Each player's board is rebuilt from its log on their next request. When the update changes the rules, it bumps model.Version, and players with an older board start a new campaign on their next request. Their old logs stay in games/.

Read the logs

  • Server: journalctl --user -u tiny-adventure -f.
  • Feedback: ~/.local/state/tiny-adventure/feedback.jsonl. Each note names its game.
  • Play: ~/.local/state/tiny-adventure/games/<game>.jsonl, one action per line.

The unit caps the server at 512 MB and half a CPU, so a busy game never starves the other services on the host.