Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Route dev helpers through managed runtime
rcourtmanb783c2d564c3
diff --git a/Makefile b/Makefileindex 7bf34b3960..d78161b22a 100644--- a/Makefile+++ b/Makefile@@ -1,6 +1,6 @@# Pulse Makefile for development-.PHONY: build run dev frontend backend all clean distclean dev-hot lint lint-backend lint-frontend format format-backend format-frontend build-agents control-plane handoff+.PHONY: build run dev dev-status dev-logs dev-stop dev-restart dev-backend-restart dev-verify frontend backend all clean distclean dev-hot lint lint-backend lint-frontend format format-backend format-frontend build-agents control-plane handoffFRONTEND_DIR := frontend-modernFRONTEND_DIST := $(FRONTEND_DIR)/dist@@ -25,9 +25,27 @@ build: frontend backendrun: build./pulse-# Development - rebuild everything and restart service-dev: frontend backend- sudo systemctl restart pulse-hot-dev+# Development - managed local runtime+dev:+ ./scripts/hot-dev-bg.sh start --takeover++dev-status:+ ./scripts/hot-dev-bg.sh status++dev-logs:+ ./scripts/hot-dev-bg.sh logs++dev-stop:+ ./scripts/hot-dev-bg.sh stop++dev-restart:+ ./scripts/hot-dev-bg.sh restart --takeover++dev-backend-restart:+ ./scripts/hot-dev-bg.sh backend-restart++dev-verify:+ ./scripts/hot-dev-bg.sh verify --takeoverdev-hot:./scripts/hot-dev.sh@@ -40,9 +58,8 @@ clean:distclean: clean./scripts/cleanup.sh-# Quick rebuild and restart for development-restart: frontend backend- sudo systemctl restart pulse-hot-dev+# Quick managed restart for development+restart: dev-restart# Run linters for both backend and frontendlint: lint-backend lint-frontenddiff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex 4f49981104..f8ebb2521d 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -35,6 +35,8 @@ server-side update execution surfaces.13. `package.json`14. `frontend-modern/package.json`15. `scripts/dev-check.sh`+16. `scripts/toggle-mock.sh`+17. `scripts/clean-mock-alerts.sh`## Shared Boundaries@@ -49,7 +51,7 @@ server-side update execution surfaces.2. Add or change release-build metadata injection, release artifact assembly, or governed promotion metadata resolution through `scripts/build-release.sh`, `scripts/release_ldflags.sh`, and `scripts/release_control/resolve_release_promotion.py`, plus the container Dockerfile and governed release workflows that consume those same contracts3. Add or change shell installer, Windows installer, container-agent installer, or auto-update script behavior through `scripts/install.sh`, `scripts/install.ps1`, `scripts/install-container-agent.sh`, and `scripts/pulse-auto-update.sh`4. Add or change server update transport through `internal/api/updates.go` and `frontend-modern/src/api/updates.ts`-5. Add or change local dev-runtime orchestration, managed ownership, browser-runtime proof wiring, frontend/backend coherence diagnostics, or the canonical developer entry wrappers through `scripts/hot-dev.sh`, `scripts/hot-dev-bg.sh`, `tests/integration/scripts/managed-dev-runtime.mjs`, `package.json`, `frontend-modern/package.json`, and `scripts/dev-check.sh`+5. Add or change local dev-runtime orchestration, managed ownership, browser-runtime proof wiring, frontend/backend coherence diagnostics, canonical developer entry wrappers, or dev-runtime helper control surfaces through `scripts/hot-dev.sh`, `scripts/hot-dev-bg.sh`, `tests/integration/scripts/managed-dev-runtime.mjs`, `package.json`, `frontend-modern/package.json`, `scripts/dev-check.sh`, `scripts/toggle-mock.sh`, and `scripts/clean-mock-alerts.sh`## Forbidden Paths@@ -188,6 +190,12 @@ operational parity with the repo-root entry surface for the canonical controls:start, status, logs, stop, restart, managed backend restart, verification, andthe explicit foreground escape hatch. The only intentionally narrower frontendworkspace exception is the named `dev:frontend-only` raw Vite escape hatch.+That same dev-runtime helper boundary also includes the auxiliary operator+controls that start, stop, restart, or recover local development. The repo-root+Makefile targets, `scripts/toggle-mock.sh`, and `scripts/clean-mock-alerts.sh` must+route through the managed runtime control plane when they are operating on the+local dev stack, instead of resurrecting lane-local `hot-dev.sh` or raw Vite+process management through separate shell folklore.That shared `scripts/install.sh` boundary must also keep one canonical serviceargument builder for the runtime flags it persists. Token-bearing installpaths, token-file systemd paths, wrapper-script launches, and later servicediff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex eef4cc31c2..dfbc908b3b 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -2036,8 +2036,10 @@"frontend-modern/package.json","frontend-modern/src/api/updates.ts","internal/api/updates.go",+ "Makefile","package.json","scripts/build-release.sh",+ "scripts/clean-mock-alerts.sh","scripts/dev-check.sh","scripts/hot-dev-bg.sh","scripts/hot-dev.sh",@@ -2047,6 +2049,7 @@"scripts/pulse-auto-update.sh","scripts/release_control/resolve_release_promotion.py","scripts/release_ldflags.sh",+ "scripts/toggle-mock.sh","tests/integration/scripts/managed-dev-runtime.mjs"],"verification": {@@ -2139,16 +2142,20 @@"match_prefixes": [],"match_files": ["frontend-modern/package.json",+ "Makefile","package.json",+ "scripts/clean-mock-alerts.sh","scripts/dev-check.sh","scripts/hot-dev-bg.sh","scripts/hot-dev.sh",+ "scripts/toggle-mock.sh","tests/integration/scripts/managed-dev-runtime.mjs"],"allow_same_subsystem_tests": false,"test_prefixes": [],"exact_files": ["scripts/tests/test-hot-dev-bg.sh",+ "scripts/tests/test-toggle-mock.sh","tests/integration/tests/16-dev-runtime-recovery.spec.ts"]},diff --git a/scripts/clean-mock-alerts.sh b/scripts/clean-mock-alerts.shindex a1e8f47a77..ee794539d0 100755--- a/scripts/clean-mock-alerts.sh+++ b/scripts/clean-mock-alerts.sh@@ -84,6 +84,7 @@ run_privileged chown pulse:pulse "$ALERT_HISTORY"echo -e "${GREEN}✓ Mock alerts removed successfully${NC}"echo ""echo "To restart the backend, run:"-echo " ./scripts/hot-dev.sh (for development)"+echo " npm run dev (managed development runtime)"+echo " ./scripts/hot-dev.sh (foreground development escape hatch)"echo " sudo systemctl start pulse (systemd)"echo " sudo systemctl start pulse-backend (legacy)"diff --git a/scripts/tests/test-toggle-mock.sh b/scripts/tests/test-toggle-mock.shnew file mode 100755index 0000000000..c025ee384d--- /dev/null+++ b/scripts/tests/test-toggle-mock.sh@@ -0,0 +1,156 @@+#!/usr/bin/env bash+#+# Smoke test for scripts/toggle-mock.sh managed runtime helpers.++set -euo pipefail++ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"+TOGGLE_MOCK="${ROOT_DIR}/scripts/toggle-mock.sh"++if [[ ! -f "${TOGGLE_MOCK}" ]]; then+ echo "toggle-mock.sh not found at ${TOGGLE_MOCK}" >&2+ exit 1+fi++failures=0+temp_dirs=()++cleanup() {+ local dir+ for dir in "${temp_dirs[@]:-}"; do+ rm -rf "${dir}" 2>/dev/null || true+ done+}+trap cleanup EXIT++assert_contains() {+ local desc="$1"+ local haystack="$2"+ local needle="$3"++ if [[ "${haystack}" == *"${needle}"* ]]; then+ echo "[PASS] ${desc}"+ else+ echo "[FAIL] ${desc}" >&2+ echo "Expected to find: ${needle}" >&2+ ((failures++))+ fi+}++make_stub_hot_dev_bg() {+ local dir+ dir="$(mktemp -d)"+ temp_dirs+=("${dir}")+ cat > "${dir}/hot-dev-bg.sh" <<'EOF'+#!/usr/bin/env bash+set -euo pipefail++COMMAND="${1:-}"+shift || true++printf "%s %s\n" "${COMMAND}" "$*" >> "${HOT_DEV_BG_STUB_LOG}"++case "${COMMAND}" in+ status)+ if [[ "${HOT_DEV_BG_STUB_RUNNING:-false}" == "true" ]]; then+ echo "[hot-dev-bg] Running (pid: 12345)"+ echo "[hot-dev-bg] Frontend shell HTTP: 200"+ echo "[hot-dev-bg] Frontend proxy /api/health: 200"+ echo "[hot-dev-bg] Backend /api/health: 200"+ else+ echo "[hot-dev-bg] Not running"+ fi+ ;;+ start)+ echo "[hot-dev-bg] Started"+ ;;+ stop)+ echo "[hot-dev-bg] Stopped"+ ;;+ *)+ echo "[hot-dev-bg] ${COMMAND}"+ ;;+esac+EOF+ chmod +x "${dir}/hot-dev-bg.sh"+ printf "%s\n" "${dir}/hot-dev-bg.sh"+}++test_detects_managed_hot_dev_runtime() {+ local stub state output+ state="$(mktemp -d)"+ temp_dirs+=("${state}")+ stub="$(make_stub_hot_dev_bg)"++ output="$(+ HOT_DEV_BG_PATH="${stub}" \+ HOT_DEV_BG_STUB_LOG="${state}/calls.log" \+ HOT_DEV_BG_STUB_RUNNING=true \+ TOGGLE_MOCK_PATH="${TOGGLE_MOCK}" \+ bash -lc '+ source "${TOGGLE_MOCK_PATH}"+ printf "mode=%s\n" "$(detect_runtime_mode)"+ '+ )"++ assert_contains "detect_runtime_mode prefers managed hot-dev" "${output}" "mode=managed-hot-dev"+}++test_managed_hot_dev_start_uses_takeover() {+ local stub state output calls+ state="$(mktemp -d)"+ temp_dirs+=("${state}")+ stub="$(make_stub_hot_dev_bg)"++ output="$(+ HOT_DEV_BG_PATH="${stub}" \+ HOT_DEV_BG_STUB_LOG="${state}/calls.log" \+ HOT_DEV_BG_STUB_RUNNING=false \+ TOGGLE_MOCK_PATH="${TOGGLE_MOCK}" \+ bash -lc '+ source "${TOGGLE_MOCK_PATH}"+ start_hot_dev_runtime+ '+ )"+ calls="$(cat "${state}/calls.log")"++ assert_contains "start_hot_dev_runtime announces managed startup" "${output}" "Starting managed hot-dev runtime"+ assert_contains "start_hot_dev_runtime uses managed takeover start" "${calls}" "start --takeover"+}++test_managed_hot_dev_stop_uses_control_plane() {+ local stub state output calls+ state="$(mktemp -d)"+ temp_dirs+=("${state}")+ stub="$(make_stub_hot_dev_bg)"++ output="$(+ HOT_DEV_BG_PATH="${stub}" \+ HOT_DEV_BG_STUB_LOG="${state}/calls.log" \+ HOT_DEV_BG_STUB_RUNNING=true \+ TOGGLE_MOCK_PATH="${TOGGLE_MOCK}" \+ bash -lc '+ source "${TOGGLE_MOCK_PATH}"+ stop_hot_dev_runtime managed-hot-dev+ '+ )"+ calls="$(cat "${state}/calls.log")"++ assert_contains "stop_hot_dev_runtime announces managed stop" "${output}" "Stopping managed hot-dev runtime"+ assert_contains "stop_hot_dev_runtime uses managed stop command" "${calls}" "stop "+}++main() {+ test_detects_managed_hot_dev_runtime+ test_managed_hot_dev_start_uses_takeover+ test_managed_hot_dev_stop_uses_control_plane++ if (( failures > 0 )); then+ echo "Total failures: ${failures}" >&2+ exit 1+ fi++ echo "toggle-mock managed runtime smoke tests passed."+}++main "$@"diff --git a/scripts/toggle-mock.sh b/scripts/toggle-mock.shindex 773f4b41ab..d6da7ca00e 100755--- a/scripts/toggle-mock.sh+++ b/scripts/toggle-mock.sh@@ -18,6 +18,7 @@ NC='\033[0m'SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"ROOT_DIR="$(dirname "$SCRIPT_DIR")"+HOT_DEV_BG_PATH="${HOT_DEV_BG_PATH:-${ROOT_DIR}/scripts/hot-dev-bg.sh}"MOCK_ENV_FILE="${ROOT_DIR}/mock.env"DEV_DATA_DIR="${ROOT_DIR}/tmp/dev-config"@@ -128,6 +129,20 @@ wait_for_port() {return 1}+run_hot_dev_bg() {+ "${HOT_DEV_BG_PATH}" "$@"+}++hot_dev_bg_status_output() {+ run_hot_dev_bg status 2>/dev/null || true+}++hot_dev_bg_is_running() {+ local output+ output="$(hot_dev_bg_status_output)"+ [[ "${output}" == *"[hot-dev-bg] Running"* ]]+}+prefer_hot_dev_runtime() {local prefer="${PULSE_TOGGLE_PREFER_HOT_DEV:-auto}"case "${prefer}" in@@ -265,6 +280,11 @@ detect_runtime_mode() {fifi+ if hot_dev_bg_is_running; then+ echo "managed-hot-dev"+ return+ fi+if pgrep -f "hot-dev.sh" >/dev/null 2>&1; thenecho "hot-dev"return@@ -310,11 +330,18 @@ wait_for_exit() {}stop_hot_dev_runtime() {+ local runtime_mode="${1:-hot-dev}"local hot_dev_pattern="${ROOT_DIR}/scripts/hot-dev.sh|scripts/hot-dev.sh|hot-dev.sh"local pulse_pattern="${ROOT_DIR}/pulse|(^|[[:space:]])\\./pulse([[:space:]]|$)"local vite_pattern="${ROOT_DIR}/frontend-modern.*vite|vite.*${ROOT_DIR}/frontend-modern|vite --config vite.config.ts"- log_info "Stopping hot-dev runtime..."+ if [[ "${runtime_mode}" == "managed-hot-dev" ]] && hot_dev_bg_is_running; then+ log_info "Stopping managed hot-dev runtime..."+ run_hot_dev_bg stop >/dev/null+ return+ fi++ log_info "Stopping legacy hot-dev runtime..."kill_with_grace "$hot_dev_pattern" TERMwait_for_exit "$hot_dev_pattern"@@ -445,45 +472,12 @@ sync_production_config() {}start_hot_dev_runtime() {- local pid- local expected_backend_port="${PULSE_TOGGLE_BACKEND_PORT:-7655}"- local expected_frontend_port="${PULSE_TOGGLE_FRONTEND_PORT:-5173}"- local startup_timeout="${PULSE_TOGGLE_HOT_DEV_START_TIMEOUT:-45}"- local frontend_dev_host="${FRONTEND_DEV_HOST:-127.0.0.1}"- local pulse_dev_api_host="${PULSE_DEV_API_HOST:-127.0.0.1}"- local pulse_dev_api_url="${PULSE_DEV_API_URL:-http://${pulse_dev_api_host}:${expected_backend_port}}"- local pulse_dev_ws_url="${PULSE_DEV_WS_URL:-ws://${pulse_dev_api_host}:${expected_backend_port}}"- log_info "Starting hot-dev runtime in background"- pid="$(- cd "${ROOT_DIR}" && launch_detached "${HOT_DEV_LOG}" \- /usr/bin/env \- FRONTEND_DEV_HOST="${frontend_dev_host}" \- FRONTEND_DEV_PORT="${expected_frontend_port}" \- PULSE_DEV_API_HOST="${pulse_dev_api_host}" \- PULSE_DEV_API_PORT="${expected_backend_port}" \- PULSE_DEV_API_URL="${pulse_dev_api_url}" \- PULSE_DEV_WS_URL="${pulse_dev_ws_url}" \- "${ROOT_DIR}/scripts/hot-dev.sh"- )"- sleep 2-- if ! pgrep -f "hot-dev.sh" >/dev/null 2>&1; then- log_error "hot-dev failed to start. Check ${HOT_DEV_LOG}"+ log_info "Starting managed hot-dev runtime..."+ if ! run_hot_dev_bg start --takeover; then+ log_error "Managed hot-dev failed to start"return 1fi-- if ! wait_for_port "${expected_backend_port}" "${startup_timeout}"; then- log_warn "hot-dev did not open backend port ${expected_backend_port} within ${startup_timeout}s"- return 2- fi-- # Frontend startup can lag behind backend startup when the dependency map is large.- if ! wait_for_port "${expected_frontend_port}" "${startup_timeout}"; then- log_warn "hot-dev backend is up but frontend port ${expected_frontend_port} is not listening yet"- log_warn "Proceeding with backend-only availability; check ${HOT_DEV_LOG} for frontend startup"- fi-- log_success "hot-dev started (pid: ${pid}, backend:${expected_backend_port}, frontend:${expected_frontend_port}, log: ${HOT_DEV_LOG})"+ log_success "Managed hot-dev runtime is running"}start_standalone_runtime() {@@ -580,8 +574,8 @@ apply_mode() {systemd-hot-dev|systemd-pulse)stop_systemd_runtime "$runtime_mode";;- hot-dev)- stop_hot_dev_runtime+ managed-hot-dev|hot-dev)+ stop_hot_dev_runtime "$runtime_mode";;standalone)stop_standalone_runtime "false"@@ -598,12 +592,12 @@ apply_mode() {# are always reflected immediately after toggling.if [[ "${runtime_mode}" == "none" ]] || [[ "${runtime_mode}" == "standalone" ]] || [[ "${runtime_mode}" == "pulse-name" ]]; thenif prefer_hot_dev_runtime; then- start_mode="hot-dev"+ start_mode="managed-hot-dev"fifi# hot-dev already handles build/reload on startup; avoid duplicate builds here for fast toggles.- if [[ "$start_mode" == "hot-dev" ]] || [[ "$start_mode" == "systemd-hot-dev" ]]; then+ if [[ "$start_mode" == "managed-hot-dev" ]] || [[ "$start_mode" == "hot-dev" ]] || [[ "$start_mode" == "systemd-hot-dev" ]]; thenlog_info "Skipping pre-rebuild for hot-dev runtime (managed by hot-dev startup)"elserebuild_frontend_backend@@ -613,11 +607,11 @@ apply_mode() {systemd-hot-dev|systemd-pulse)start_systemd_runtime "$start_mode";;- hot-dev)+ managed-hot-dev|hot-dev)if ! start_hot_dev_runtime; thenif [[ "${allow_fallback}" == "true" ]]; thenlog_warn "hot-dev restart failed or is unhealthy; falling back to standalone backend on port ${DEFAULT_PORT}"- stop_hot_dev_runtime || true+ stop_hot_dev_runtime "$start_mode" || truestart_standalone_runtime "$target_mode"start_mode="standalone"else@@ -631,7 +625,7 @@ apply_mode() {;;esac- if [[ "$start_mode" == "hot-dev" ]]; then+ if [[ "$start_mode" == "managed-hot-dev" ]] || [[ "$start_mode" == "hot-dev" ]]; thenif ! verify_mock_state_via_frontend_proxy "$target_mode"; thenlog_error "Frontend proxy at 127.0.0.1:5173 did not report expected mock state (${target_mode})"return 1@@ -767,4 +761,6 @@ main() {esac}-main "$@"+if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then+ main "$@"+fi