Files
2026-11-16 17:26:44 -08:00

29 lines
1.1 KiB
Bash

#!/usr/bin/env bash
# Local DEBUG session: control-plane backend (hot reload) + control-web frontend
# (Vite dev) in ONE terminal. The Vite dev server proxies /api + /ws to the LOCAL
# backend, so the frontend loads against THIS backend — not the prod FaaS one.
# (import.meta.env.DEV → API_BASE="" → relative → proxy → local.) Ctrl-C stops both.
#
# Note: the local backend still uses DATABASE_URL from .env — set it to a debug DB
# if you don't want to touch prod data.
set -uo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
echo "[debug] starting control-plane backend (hot) + control-web (vite dev)…"
# backend — hot reload; STREAMLINE_DEBUG marks the session as debug.
STREAMLINE_DEBUG=1 bun run --hot control-server/src/index.ts &
BACK=$!
# frontend — Vite dev server (proxies /api + /ws to the local backend).
( cd control-web && bun run dev ) &
FRONT=$!
# stop both on Ctrl-C / exit / if either child dies. (Portable to macOS bash 3.2,
# which lacks `wait -n` — poll liveness instead.)
trap 'kill "$BACK" "$FRONT" 2>/dev/null' INT TERM EXIT
while kill -0 "$BACK" 2>/dev/null && kill -0 "$FRONT" 2>/dev/null; do
sleep 1
done