Upstream/deploy/upstream-offsite.service
jvanvik 3c23c51902 Phase 4: close loot/refund leaks, landing-site garrisons, speed-scaled shipping, update/offsite tooling, broad e2e
Built:
- Economy: raid loot capped to the room the raiders have at home (rest stays with the victim, "lootLeft" in the report); trade escrow reserves its room so refunds always fit; trade accept refuses with no_room_for_goods when the goods would not fit. Loot destroyed per 30-day run 31-61k -> ~1k, refunds clipped ~27k -> 0 (docs/BALANCE.md, 3 seeds).
- End game: members of the holding alliance garrison landing sites (migration 005_site_garrison.sql), garrison counts in site defence, 72 h capture shield, withdraw route, POP view lists garrisoned units. Shipping capacity scales with world speed (3x world: winner 76-98 -> ~30-36 days after sites open). Bot runs show real contests (84-194 attacks on held sites at 1x).
- Ops: deploy/update.sh (backup, stop, ff-merge, npm ci --ignore-scripts, health check, rollback), deploy/upstream-offsite (rsync only), admin end-world snapshots results, EPIPE fix, docs/workflows/ filled in.
- e2e 62 -> 163 checks: units, raids/reports, alliance+messages, trade, end game, nb, PWA, reconnect, slow polling fallback (opt-in). Two app bugs found: message push ignored, "New" button stayed English.

Tested: npm test 274/274, openapi check, npm run e2e 163/163 (137 s), bot runs 50x30d seeds 1-3 and 140-day/60-day speed-3 end-game runs INVARIANTS OK, adversarial review pass (findings fixed or documented).
NOT tested: update.sh on a real box (systemd, real npm, runuser; stubs only, shellcheck not installed), garrison card/loot text on a phone, Node 22.13, humans. Known leaks left open and documented (BALANCE S6): loot/shipments can still overflow when stock arrives in flight, bounced backbone shipments lose overflow (reported to the sender). Garrison numbers (heldDefenceMult 2, shield 72 h) are first guesses from 2 seeds. Not claimed: balanced.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
2026-10-12 00:58:12 +02:00

43 lines
1.9 KiB
Desktop File

# Copy the newest verified snapshot off the box (rsync to OFFSITE_DEST). Started by upstream-offsite.timer, or by hand:
# systemctl start upstream-offsite. Does NOTHING until OFFSITE_DEST is set in /etc/upstream/upstream.env: the ExecCondition
# below then makes systemd skip the run quietly (no failure). See docs/DEPLOY.md section 7, "Off-box copy".
#
# install -m 0644 deploy/upstream-offsite.service deploy/upstream-offsite.timer /etc/systemd/system/
# (after configuring) systemctl daemon-reload && systemctl enable --now upstream-offsite.timer
#
# Instead of the timer you can chain it to the backup: `systemctl edit upstream-backup` and add
# [Unit]
# OnSuccess=upstream-offsite.service
[Unit]
Description=Upstream - copy the newest verified snapshot off the box
Documentation=file:///opt/upstream/docs/DEPLOY.md
# Not tied to upstream.service: copying a snapshot must work while the game is stopped.
[Service]
Type=oneshot
User=upstream
Group=upstream
WorkingDirectory=/opt/upstream
# OFFSITE_DEST, OFFSITE_METHOD, OFFSITE_SSH_KEY, OFFSITE_KNOWN_HOSTS, OFFSITE_SSH_OPTS, BACKUP_DIR: see deploy/upstream-offsite.
EnvironmentFile=-/etc/upstream/upstream.env
Environment=BACKUP_DIR=/var/lib/upstream/backups
Environment=UPSTREAM_ADMIN=/usr/local/bin/upstream-admin
# Exit 1 from ExecCondition = skipped (not failed) when OFFSITE_DEST is unset or empty.
ExecCondition=/opt/upstream/deploy/upstream-offsite --check
ExecStart=/opt/upstream/deploy/upstream-offsite
# A failed copy must be visible: the unit fails and journalctl -u upstream-offsite shows why.
TimeoutStartSec=30min
Nice=10
IOSchedulingClass=idle
NoNewPrivileges=yes
CapabilityBoundingSet=
AmbientCapabilities=
# ssh/rsync need IP sockets; AF_UNIX for an ssh-agent or the resolver, AF_NETLINK for glibc's resolver (as in upstream.service)
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK
RestrictRealtime=yes
RestrictSUIDSGID=yes
LockPersonality=yes
SystemCallArchitectures=native
UMask=0077