96fd910603
- Add concurrency limiter (max 4 GET requests) to API layer, leaving slots for SSE and health checks. Write ops bypass the limiter. - Add AbortController to ContainerStats, project detail page, and dashboard to cancel in-flight requests on navigation/unmount. - Move global SSE connection from layout to events page (only consumer). - Add 30s heartbeat to SSE endpoint to detect zombie connections. - Serialize dashboard project fetches to avoid parallel burst. - Rebuild frontend in dev-server.sh so go:embed stays in sync.
42 lines
1.3 KiB
Bash
42 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Start (or restart) the Tinyforge dev server on port 8090.
|
|
# Usage: ./scripts/dev-server.sh
|
|
|
|
set -euo pipefail
|
|
|
|
PORT="${LISTEN_ADDR:-:8090}"
|
|
PORT_NUM="${PORT#:}"
|
|
|
|
# Kill existing process on the port if any.
|
|
PID=$(netstat -aon 2>/dev/null | grep ":${PORT_NUM}.*LISTEN" | awk '{print $5}' | head -1)
|
|
if [ -n "$PID" ] && [ "$PID" != "0" ]; then
|
|
echo "Stopping existing process on port ${PORT_NUM} (PID ${PID})..."
|
|
taskkill //F //PID "$PID" 2>/dev/null || kill "$PID" 2>/dev/null || true
|
|
sleep 1
|
|
fi
|
|
|
|
# Use a stable encryption key for development.
|
|
# Generate once and save to data/.dev-key so encrypted tokens survive restarts.
|
|
if [ -z "${ENCRYPTION_KEY:-}" ]; then
|
|
KEY_FILE="./data/.dev-key"
|
|
mkdir -p ./data
|
|
if [ -f "$KEY_FILE" ]; then
|
|
ENCRYPTION_KEY=$(cat "$KEY_FILE")
|
|
else
|
|
ENCRYPTION_KEY=$(openssl rand -hex 32)
|
|
echo "$ENCRYPTION_KEY" > "$KEY_FILE"
|
|
echo "Generated new dev encryption key (saved to $KEY_FILE)"
|
|
fi
|
|
fi
|
|
export ENCRYPTION_KEY
|
|
export ADMIN_PASSWORD="${ADMIN_PASSWORD:-admin123}"
|
|
export LISTEN_ADDR="${PORT}"
|
|
|
|
# Rebuild frontend so go:embed picks up changes.
|
|
echo "Building frontend..."
|
|
(cd web && npm run build --silent)
|
|
|
|
echo "Starting Tinyforge on http://localhost:${PORT_NUM}"
|
|
echo "Login: admin / ${ADMIN_PASSWORD}"
|
|
exec go run ./cmd/server
|