Files
waving-hands/deploy/deploy.sh
T
Eric WagonerandClaude Opus 5.5 151d82e747 Traffic counts what matters: rooms opened from the site, where links were shared, scanners and monitors as bots
- A room opened with Play now never loads /join: the API's answer to
  POST /api/rooms is counted as rooms opened here.
- Link previews (Slack, Discord, Facebook, iMessage, WhatsApp and the
  rest) are reported as where the link was shared, since the people who
  click them arrive with no referrer. WhatsApp's fetcher is a bot now.
- An address that asks for a scanner's paths, or keeps coming back
  without opening a game, is a bot's all day; so is a browser that loads
  pages at a steady interval from a new address each time, never
  playing. A declared bot is still judged request by request.
- The site's own addresses, sslip.io included, are not referrers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
2026-09-27 10:00:53 -04:00

56 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build locally, push the static site and the duel server to the droplet,
# and restart the server. Usage: deploy/deploy.sh <droplet-ip-or-host>
set -euo pipefail
HOST="${1:?usage: deploy.sh <droplet-ip-or-host>}"
# The family list is the kit's; a game deploys with the kit's latest copy when the kit is beside it.
KIT_FAMILY="$(dirname "$0")/../../game-kit/family.json"
[ -f "$KIT_FAMILY" ] && cp "$KIT_FAMILY" static/family.json
npm run check
npm run check:server
npm test
npm run build
# Every production ledger must replay identically with the engine about to ship.
deploy/verify-ledgers.sh "$HOST"
# Old hashed chunks stay a week: a page loaded before this deploy can still
# fetch the module it was built against instead of failing mid-duel.
rsync -az --delete --filter='P _app/immutable/*' \
build/ "root@$HOST:/opt/waving-hands/build/"
# The server runs from source with tsx and carries its own small manifest;
# it needs only its code and the engine. Ledgers live outside this tree.
rsync -az --delete --exclude='/server/node_modules' \
--include='/server/***' --include='/src/' --include='/src/lib/' --include='/src/lib/game/***' \
--include='/deploy/' --include='/deploy/waving-hands.service' --include='/deploy/waving-hands.cron' --include='/deploy/*.sh' --include='/deploy/hash-tokens.ts' --include='/deploy/traffic.py' \
--exclude='*' \
./ "root@$HOST:/opt/waving-hands/app/"
ssh "root@$HOST" '
find /opt/waving-hands/build/_app/immutable -type f -mtime +7 -delete
chown -R root:caddy /opt/waving-hands/build
chmod -R g+rX /opt/waving-hands/build
cd /opt/waving-hands/app/server && npm install --no-audit --no-fund
chown -R waving-hands:waving-hands /opt/waving-hands/app
cp /opt/waving-hands/app/deploy/waving-hands.service /etc/systemd/system/waving-hands.service
# Cron runs the rollup and the backup from /usr/local/bin: install them on
# every deploy so the live copies are always the repo copies.
install -m 755 /opt/waving-hands/app/deploy/visitors.sh /usr/local/bin/waving-hands-visitors.sh
install -m 644 -D /opt/waving-hands/app/deploy/traffic.py /usr/local/lib/waving-hands/traffic.py
install -m 755 /opt/waving-hands/app/deploy/pulse.sh /usr/local/bin/waving-hands-pulse.sh
install -m 755 /opt/waving-hands/app/deploy/waving-hands-rollup.sh /usr/local/bin/waving-hands-rollup.sh
install -m 755 /opt/waving-hands/app/deploy/waving-hands-backup.sh /usr/local/bin/waving-hands-backup.sh
install -m 644 /opt/waving-hands/app/deploy/waving-hands.cron /etc/cron.d/waving-hands
mkdir -p /var/log/waving-hands
systemctl daemon-reload
systemctl enable --now waving-hands
systemctl restart waving-hands
systemctl reload caddy
sleep 1
systemctl --no-pager -l status waving-hands | head -3
'
echo "deployed."