feat(m4): LAN playtest run script (devbox run serve) (#80)
One command builds the client dist and server binary, then starts the loopback server behind the DESIGN 11.1 TLS/HTTP2 nginx on the detected LAN address. State, GM key and certificate persist under run/lan so a table and a phone's trust survive Ctrl-C/restart; the certificate is regenerated when the address changes. Prints the URL, GM key and Android/laptop trust steps. tools/nginx.mjs and tools/tlsdev.mjs gained the bind/SAN knobs the LAN needs (test defaults unchanged). tools/serve.test.mjs proves h2 + verified TLS on /healthz and /, POST /join, a /ws upgrade on the LAN address, loopback-only server binding, and identical key/cert after a restart.
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# devbox run serve (M4 #80): one command for a LAN playtest.
|
||||
#
|
||||
# Builds the server binary (run/fff-vtt) and the client dist (client/dist), then starts the
|
||||
# TLS/HTTP2 nginx on the LAN address in front of the loopback server and blocks. Ctrl-C stops both
|
||||
# processes. State, GM key and certificate live under the state dir (default run/lan) and are
|
||||
# reused by the next run.
|
||||
#
|
||||
# devbox run serve # detected LAN IP, port 8443, state run/lan
|
||||
# FFF_VTT_LAN_PORT=9443 devbox run serve
|
||||
# FFF_VTT_STATE_DIR=run/lan2 devbox run serve
|
||||
# FFF_VTT_LAN_HOST=192.168.1.50 devbox run serve # override the detected address
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.." || exit 1
|
||||
|
||||
STATE_DIR="${FFF_VTT_STATE_DIR:-run/lan}"
|
||||
mkdir -p "$STATE_DIR" run
|
||||
|
||||
# Dependencies (idempotent) and the server binary. The worktree-local nimcache is deliberate: Nim's
|
||||
# default cache is shared by every checkout, and two parallel worktrees corrupt each other.
|
||||
nimble install -d -y
|
||||
NIMBLE_PKGS="${NIMBLE_DIR:-.devbox/nimble}/pkgs2"
|
||||
nim c --hints:off --mm:orc --nimblePath:"$NIMBLE_PKGS" \
|
||||
--nimcache:run/nimcache/fff-vtt -o:run/fff-vtt server/main.nim
|
||||
|
||||
# The client build nginx serves at `/`.
|
||||
( cd client
|
||||
if [ ! -d node_modules ]; then npm ci --no-audit --no-fund; fi
|
||||
npm run build
|
||||
)
|
||||
|
||||
exec node tools/serve.mjs "$@"
|
||||
Reference in New Issue
Block a user