From 08d50be49093e5548c2611d0238cabcfaef3ed21 Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Tue, 9 Jun 2026 23:16:04 -0400 Subject: [PATCH] Track devserver.sh and finish the tower -> beacon rename scripts/ was caught by a stray .gitignore entry, so the npm start/stop helpers pointed at a file fresh clones never got. Also sweep the last tower-* references out of comments, compose and the map test fixture. --- .gitignore | 1 - docker/docker-compose.yml | 2 +- scripts/devserver.sh | 92 +++++++++++++++++++ src/features/observers/ObserverTable.tsx | 2 +- src/features/stats/types.ts | 2 +- tests/features/map/node-geojson.test.ts | 4 +- .../packets/payload-renderers.test.tsx | 2 +- vite.config.ts | 2 +- 8 files changed, 99 insertions(+), 8 deletions(-) create mode 100755 scripts/devserver.sh diff --git a/.gitignore b/.gitignore index b20f5fd..dda69a2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ dist/ build/ .next/ .nuxt/ -scripts/ # Dev server helper runtime files .scripts/ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index fd00cc8..f449012 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -13,7 +13,7 @@ services: restart: unless-stopped beacon-web: - image: ghcr.io/meshcore-tower/beacon-web:latest + image: ghcr.io/meshcore-beacon/beacon-web:latest environment: - VITE_API_BASE=${VITE_API_BASE:?VITE_API_BASE environment variable is required} - VITE_WS_URL=${VITE_WS_URL:?VITE_WS_URL environment variable is required} diff --git a/scripts/devserver.sh b/scripts/devserver.sh new file mode 100755 index 0000000..bb55e81 --- /dev/null +++ b/scripts/devserver.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +# Start/stop helper for the beacon-web Vite dev server. +# +# Usage: +# scripts/devserver.sh start # launch on a fixed port (background) +# scripts/devserver.sh stop # stop the server this script started +# scripts/devserver.sh restart # stop then start +# scripts/devserver.sh status # is it running? on what URL? +# scripts/devserver.sh stop-all # kill ALL stray vite processes (cleanup) +# +# Port defaults to 5173; override with BEACON_WEB_PORT=NNNN. +set -euo pipefail + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +PORT="${BEACON_WEB_PORT:-5173}" +RUNTIME_DIR="$DIR/.scripts" +PID_FILE="$RUNTIME_DIR/devserver.pid" +LOG_FILE="$RUNTIME_DIR/devserver.log" +VITE_BIN="$DIR/node_modules/vite/bin/vite.js" + +is_alive() { [ -f "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; } + +start() { + if is_alive; then + echo "dev server already running (pid $(cat "$PID_FILE")) — $(url)" + return 0 + fi + if [ ! -f "$VITE_BIN" ]; then + echo "vite not found at $VITE_BIN — run 'npm install' first" >&2 + exit 1 + fi + mkdir -p "$RUNTIME_DIR" + # --strictPort: fail loudly if the port is taken instead of silently drifting. + nohup node "$VITE_BIN" --port "$PORT" --strictPort >"$LOG_FILE" 2>&1 & + echo $! >"$PID_FILE" + # Give Vite a moment to bind (or fail) so status output is accurate. + for _ in $(seq 1 20); do + grep -q "Local:" "$LOG_FILE" 2>/dev/null && break + is_alive || { echo "dev server failed to start — see $LOG_FILE" >&2; rm -f "$PID_FILE"; tail -n 5 "$LOG_FILE" >&2; exit 1; } + sleep 0.25 + done + echo "dev server started (pid $(cat "$PID_FILE")) — $(url)" +} + +stop() { + local stopped=0 + if is_alive; then + local pid; pid="$(cat "$PID_FILE")" + kill "$pid" 2>/dev/null || true + pkill -P "$pid" 2>/dev/null || true # any children Vite spawned + stopped=1 + fi + # Also free the port in case a previous, untracked run is holding it. + local port_pids; port_pids="$(lsof -ti "tcp:$PORT" 2>/dev/null || true)" + if [ -n "$port_pids" ]; then + echo "$port_pids" | xargs kill 2>/dev/null || true + stopped=1 + fi + rm -f "$PID_FILE" + [ "$stopped" = 1 ] && echo "dev server stopped" || echo "dev server was not running" +} + +status() { + if is_alive; then + echo "running (pid $(cat "$PID_FILE")) — $(url)" + else + echo "not running" + fi +} + +# Best-effort cleanup of the stale instances that pile up across sessions. +# Matches any vite launched from THIS project's node_modules (covers both the +# `.bin/vite` symlink used by `npm run dev` and the resolved `vite/bin/vite.js` +# used by this script) so it won't touch other projects' servers. +stop_all() { + pkill -f "$DIR/node_modules/.*vite" 2>/dev/null && echo "killed stray beacon-web vite processes" || echo "no stray beacon-web vite processes found" + rm -f "$PID_FILE" +} + +# Read the actual URL Vite reported (handles the case where the port differs). +url() { + grep -oE "http://localhost:[0-9]+/?" "$LOG_FILE" 2>/dev/null | head -1 || echo "http://localhost:$PORT/" +} + +case "${1:-}" in + start) start ;; + stop) stop ;; + restart) stop; start ;; + status) status ;; + stop-all) stop_all ;; + *) echo "usage: $0 {start|stop|restart|status|stop-all}" >&2; exit 2 ;; +esac diff --git a/src/features/observers/ObserverTable.tsx b/src/features/observers/ObserverTable.tsx index bbe6975..a8599f8 100644 --- a/src/features/observers/ObserverTable.tsx +++ b/src/features/observers/ObserverTable.tsx @@ -149,7 +149,7 @@ export function ObserverTable({ wsManager, selectedObserverId, onSelectObserver, // patch the live status into the paged cache (mirrors NodeTable). A brand-new observer not on any // loaded page isn't pulled in here — it surfaces on the next reload/region switch (see the - // tower-docs ticket about carrying the full summary in WS events for true live insertion). + // beacon-docs ticket about carrying the full summary in WS events for true live insertion). const handleObserverStatus = useCallback( (data: WsObserverStatus["data"]) => { queryClient.setQueryData>>(queryKey, (old) => diff --git a/src/features/stats/types.ts b/src/features/stats/types.ts index 405d1bf..8274b0c 100644 --- a/src/features/stats/types.ts +++ b/src/features/stats/types.ts @@ -1,4 +1,4 @@ -// Response shapes for the /stats/* endpoints and observer telemetry. Verified against tower-server. +// Response shapes for the /stats/* endpoints and observer telemetry. Verified against beacon-server. export interface StatsOverview { totalPackets: number; diff --git a/tests/features/map/node-geojson.test.ts b/tests/features/map/node-geojson.test.ts index b943b37..68fb6c6 100644 --- a/tests/features/map/node-geojson.test.ts +++ b/tests/features/map/node-geojson.test.ts @@ -31,11 +31,11 @@ describe("nodesToFeatureCollection", () => { it("carries id/name/nodeTypeName/isObserver as feature properties", () => { const fc = nodesToFeatureCollection([ - node({ id: "abc", name: "Tower A", nodeType: 2, nodeTypeName: "sensor" }), + node({ id: "abc", name: "Relay A", nodeType: 2, nodeTypeName: "sensor" }), ]); expect(fc.features[0]!.properties).toEqual({ id: "abc", - name: "Tower A", + name: "Relay A", nodeTypeName: "sensor", isObserver: false, }); diff --git a/tests/features/packets/payload-renderers.test.tsx b/tests/features/packets/payload-renderers.test.tsx index aeb5e6a..f84c905 100644 --- a/tests/features/packets/payload-renderers.test.tsx +++ b/tests/features/packets/payload-renderers.test.tsx @@ -48,7 +48,7 @@ describe("PayloadBreakdown — trace resolvedRoute overlay", () => { describe("PayloadBreakdown — GROUP_TEXT decrypted channel message", () => { // Backend GetPacket enrichment nests decrypted:{sender,content,sentAt} (sentAt is epoch ms). - // See tower-server db/packets.go + internal/ingest/side_effects.go. + // See beacon-server db/packets.go + internal/ingest/side_effects.go. // chosen so the ms reading (5:43 p.m.) and the wrong seconds reading (1:13 p.m.) differ const sentAt = 1_700_001_800_000; // epoch ms const payload = { diff --git a/vite.config.ts b/vite.config.ts index 57fb0ab..4b77772 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,7 +5,7 @@ import tailwindcss from "@tailwindcss/vite"; export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), "VITE_"); - // set VITE_DEV_PROXY to point at a running tower-server instance + // set VITE_DEV_PROXY to point at a running beacon-server instance const proxyTarget = env.VITE_DEV_PROXY; return {