#!/usr/bin/env bash # Run the backend and the Vite dev server together. # # ./scripts/dev.sh # # The Go server runs in the background; the Vite dev server runs in the # foreground. Ctrl-C stops both. Vite proxies /api to the Go server, so the # browser sees one origin and sessions behave exactly as in production. set -euo pipefail cd "$(dirname "$0")/.." # A local preview instance, so this works on a fresh clone without touching # your real media or your real database. export VELLUM_DATA_DIR="${VELLUM_DATA_DIR:-$PWD/demo/data}" export VELLUM_CONFIG_DIR="${VELLUM_CONFIG_DIR:-$PWD/demo/config}" export VELLUM_LISTEN="${VELLUM_LISTEN:-127.0.0.1:7788}" export VELLUM_ADMIN_USER="${VELLUM_ADMIN_USER:-admin}" export VELLUM_ADMIN_PASSWORD="${VELLUM_ADMIN_PASSWORD:-vellumdemo}" export VELLUM_LOG_LEVEL="${VELLUM_LOG_LEVEL:-info}" if ! command -v go >/dev/null 2>&1; then export PATH="$PATH:/usr/lib/golang/bin" fi echo "building backend..." CGO_ENABLED=0 go build -trimpath -o vellum ./cmd/vellum echo "starting backend on ${VELLUM_LISTEN}" ./vellum & BACKEND=$! cleanup() { echo echo "stopping backend..." kill "$BACKEND" 2>/dev/null || true wait "$BACKEND" 2>/dev/null || true } trap cleanup EXIT INT TERM # Wait for the API to answer before handing over to Vite, so the first page # load does not race the backend's startup. for _ in $(seq 1 50); do if curl -fsS -m 1 "http://${VELLUM_LISTEN#*:}/healthz" >/dev/null 2>&1; then break fi if ! kill -0 "$BACKEND" 2>/dev/null; then echo "backend exited during startup" >&2 exit 1 fi sleep 0.1 done echo echo "backend: http://${VELLUM_LISTEN} (${VELLUM_ADMIN_USER} / ${VELLUM_ADMIN_PASSWORD})" echo "frontend: http://localhost:5173" echo cd web pnpm install --silent pnpm dev