mono updates

This commit is contained in:
Devin Zuczek
2026-08-15 16:51:50 -04:00
parent 66c09806f9
commit 8e0f090d18
15 changed files with 185 additions and 28 deletions
+7 -2
View File
@@ -16,7 +16,9 @@ recflare_load_env
# custom domain via `--domain`. This keeps the real domain out of versioned files
# — committed wrangler.jsonc has no routes, and the base domain is passed as the
# DOMAIN var at runtime. Per-app subdomain overrides come from RECFLARE_SUBDOMAINS
# (a JSON object, e.g. {"playersettings":"settings"}).
# (a JSON object, e.g. {"playersettings":"settings"}); an override of "@" (or "")
# puts the worker on the APEX of the domain instead of a subdomain, which is what
# the combined `mono` worker wants — it serves every service from a path on one host.
if [ -z "${RECFLARE_DOMAIN:-}" ]; then
echo "error: RECFLARE_DOMAIN is not set — export it or add it to .env (see .env.example)" >&2
exit 1
@@ -29,7 +31,10 @@ SUBDOMAINS_JSON=${RECFLARE_SUBDOMAINS:-}
DIR=$(basename "$PWD")
# Per-app subdomain override, falling back to the worker's directory name.
SUBDOMAIN=$(printf '%s' "$SUBDOMAINS_JSON" | jq -r --arg d "$DIR" '.[$d] // $d')
HOST="$SUBDOMAIN.$DOMAIN"
case "$SUBDOMAIN" in
"" | "@") HOST="$DOMAIN" ;;
*) HOST="$SUBDOMAIN.$DOMAIN" ;;
esac
# Splice deploy-time resource ids into a generated config. The committed
# wrangler.jsonc carries "local" placeholders so it needs no per-developer edits;
+12 -1
View File
@@ -14,6 +14,15 @@ NAME=$(jq -r '.name' package.json)
recflare_load_env
EXTRA_VARS=$(recflare_vars)
# The base domain isn't a tuning knob (recflare_vars skips the deploy inputs), so pass it
# the same way a deploy does. It matters locally for the workers that hand out addresses —
# `ns`, and the combined `mono` worker, whose discovery document IS the thing you point a
# client at. Unset, the worker keeps the placeholder default in its wrangler.jsonc; running
# mono behind a tunnel, set RECFLARE_DOMAIN to the hostname that reaches it and the document
# it serves names that host instead of a domain nothing here answers on.
DOMAIN_VAR=""
[ -z "${RECFLARE_DOMAIN:-}" ] || DOMAIN_VAR="--var DOMAIN:$RECFLARE_DOMAIN"
# Give each worker a stable, unique dev port so `turbo dev` can run them all in
# parallel without colliding on wrangler's default 8787 (and its 9229 inspector
# port). The offset is the worker's alphabetical position among its siblings, so
@@ -27,9 +36,11 @@ OFFSET=$(
PORT=$((8787 + OFFSET - 1))
INSPECTOR_PORT=$((9229 + OFFSET - 1))
# $EXTRA_VARS is intentionally unquoted — it's a flag list to word-split on.
# $EXTRA_VARS and $DOMAIN_VAR are intentionally unquoted — they're flag lists to word-split
# on, and neither a knob value nor a domain contains whitespace.
exec wrangler dev \
--var NAME:"$NAME" \
$DOMAIN_VAR \
$EXTRA_VARS \
--port "$PORT" \
--inspector-port "$INSPECTOR_PORT" \