mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-10-22 18:51:21 +00:00
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.
This commit is contained in:
1 parent
add53ba7e7
commit
08d50be490
8 files changed
+99
-8
No files matched your search
@@ -6,7 +6,6 @@ dist/
|
||||
build/
|
||||
.next/
|
||||
.nuxt/
|
||||
scripts/
|
||||
|
||||
# Dev server helper runtime files
|
||||
.scripts/
|
||||
|
||||
@@ -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}
|
||||
|
||||
Executable
+92
@@ -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
|
||||
@@ -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<InfiniteData<CursorPage<ObserverSummary>>>(queryKey, (old) =>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user