Something went wrong. Try again.
Something went wrong. Try again.
cavu-games dev.sh
2.7 kB · 52 lines
Shell
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253#!/usr/bin/env bash# Local Cavu, end to end:# vivarium (a whole local atmosphere: PDS, PLC, OAuth) :2580# cavu.games host (catalog, sign-in, launcher) :8787# play.cavu.games gateway + published games :8788# your dev node, serving games/ with hot reload :8790 (+ iroh)# Ctrl-C stops everything. State lives in .dev (delete it for a fresh world).set -euo pipefailcd "$(dirname "$0")"DATA="${CAVU_DEV_DATA:-$PWD/.dev}"GAMES="${1:-$PWD/games}"mkdir -p "$DATA"/{play,host,node,vivarium}
# Always build (incremental, quick when nothing changed) so the stack never runs stale binaries../build.sh >/dev/null && cargo build --release -p cavu-hostfor port in 8787 8788 8790; do if lsof -nP -iTCP:$port -sTCP:LISTEN >/dev/null 2>&1; then echo "port $port is in use (another cavu running?)"; exit 1; fidonetrap 'kill $(jobs -p) 2>/dev/null || true' EXIT
if ! curl -sf localhost:2580/xrpc/localhost.vivarium.getInfo >/dev/null; then echo "starting vivarium…" npx -y @vivarium-dev/cli --data "$DATA/vivarium" > "$DATA/vivarium.log" 2>&1 & for _ in $(seq 1 60); do curl -sf localhost:2580/xrpc/localhost.vivarium.getInfo >/dev/null && break; sleep 1; donefifor h in alice bob; do curl -sf -X POST localhost:2580/xrpc/localhost.vivarium.createAccount -H 'content-type: application/json' \ -d "{\"handle\":\"$h.vivarium.test\"}" >/dev/null 2>&1 || truedone
./target/release/cavu-server --did 'did:web:127.0.0.1%3A8788' --public-url http://127.0.0.1:8788 \ --host-url http://127.0.0.1:8787 --plc-url http://localhost:2580 --data "$DATA/play" > "$DATA/play.log" 2>&1 &./target/release/cavu-host --dev-launch-did 'did:web:127.0.0.1%3A8788' --plc-url http://localhost:2580 \ --gateway-url http://127.0.0.1:8788 --appview-url http://localhost:2580 --data "$DATA/host" > "$DATA/host.log" 2>&1 &sleep 1
did() { curl -s "localhost:2580/xrpc/com.atproto.identity.resolveHandle?handle=$1" | sed -E 's/.*"did":"([^"]+)".*/\1/'; }cat <<MSG
Catalog: http://127.0.0.1:8787/ (use 127.0.0.1, not localhost) Sign in: paste a DID into the sign-in box (vivarium handles don't resolve via public DNS): alice $(did alice.vivarium.test) bob $(did bob.vivarium.test) Records: curl 'localhost:2580/xrpc/com.atproto.repo.listRecords?repo=<did>&collection=games.cavu.score' Logs: $DATA/{play,host,vivarium}.log
Published games (Play on the catalog) save records. Games played from the dev node never write records. Edit Lua under $GAMES and it hot-reloads.
MSG./target/release/cavu-server --dev-node --port 8790 --games "$GAMES" \ --gateway-url http://127.0.0.1:8788 --host-url http://127.0.0.1:8787 --plc-url http://localhost:2580 --data "$DATA/node"