#!/usr/bin/env bash # Lifecycle wrapper for the playground dev server (fixed port 6203). # # `start` detaches Vite into its own session via `setsid` so the launching # shell returns immediately and the server keeps running independently — no # lingering foreground/background shell tied to it. Output goes to $LOG. set -euo pipefail PORT=6203 LOG="/tmp/solid-stage-playground.log" ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" running() { lsof -ti "tcp:${PORT}" >/dev/null 2>&1 } start() { if running; then echo "playground already running on port ${PORT}" return 0 fi cd "${ROOT}" # setsid → new session (detached from this shell's controlling terminal); # "${LOG}" 2>&1 /dev/null || true echo "freed port ${PORT}" } case "${1:-}" in start) start ;; stop) stop ;; restart) stop sleep 1 start ;; *) echo "usage: $(basename "$0") {start|stop|restart}" >&2 exit 1 ;; esac