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
Harden managed dev backend recovery
rcourtman8554754f3e54
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex ab696ceb75..77d962d1c8 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -62,6 +62,7 @@ server-side update execution surfaces.37. `scripts/dev-launchd-wrapper.sh`38. `scripts/hot-dev-bg.sh`39. `scripts/hot-dev.sh`+40. `scripts/lib/hot-dev-runtime.sh`40. `scripts/install-container-agent.sh`41. `install.sh`42. `scripts/install.ps1`@@ -169,7 +170,7 @@ server-side update execution surfaces.enrollment runtime tokens while keeping deploy binding metadata limited todeploy facts such as cluster, job, target, source agent, and expected node.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, canonical developer entry wrappers, dependency manifest floors, frontend build chunking, or dev-runtime helper control surfaces through `scripts/hot-dev.sh`, `scripts/hot-dev-bg.sh`, `scripts/dev-deploy-agent.sh`, `Makefile`, `package.json`, `package-lock.json`, `frontend-modern/package.json`, `frontend-modern/package-lock.json`, `frontend-modern/vite.config.ts`, `go.mod`, `go.sum`, `scripts/dev-check.sh`, `scripts/toggle-mock.sh`, `scripts/clean-mock-alerts.sh`, `scripts/dev-launchd-setup.sh`, `scripts/dev-launchd-wrapper.sh`, `scripts/run_demo_public_browser_smoke.sh`, `scripts/demo_public_browser_smoke.cjs`, `scripts/com.pulse.hot-dev.plist.template`, `tests/integration/scripts/managed-dev-runtime.mjs`, `tests/integration/playwright.config.ts`, `tests/integration/tests/helpers.ts`, `tests/integration/tests/runtime-defaults.ts`, `tests/integration/README.md`, and `tests/integration/QUICK_START.md`+5. Add or change local dev-runtime orchestration, managed ownership, browser-runtime proof wiring, frontend/backend coherence diagnostics, canonical developer entry wrappers, dependency manifest floors, frontend build chunking, or dev-runtime helper control surfaces through `scripts/hot-dev.sh`, `scripts/hot-dev-bg.sh`, `scripts/lib/hot-dev-runtime.sh`, `scripts/dev-deploy-agent.sh`, `Makefile`, `package.json`, `package-lock.json`, `frontend-modern/package.json`, `frontend-modern/package-lock.json`, `frontend-modern/vite.config.ts`, `go.mod`, `go.sum`, `scripts/dev-check.sh`, `scripts/toggle-mock.sh`, `scripts/clean-mock-alerts.sh`, `scripts/dev-launchd-setup.sh`, `scripts/dev-launchd-wrapper.sh`, `scripts/run_demo_public_browser_smoke.sh`, `scripts/demo_public_browser_smoke.cjs`, `scripts/com.pulse.hot-dev.plist.template`, `tests/integration/scripts/managed-dev-runtime.mjs`, `tests/integration/playwright.config.ts`, `tests/integration/tests/helpers.ts`, `tests/integration/tests/runtime-defaults.ts`, `tests/integration/README.md`, and `tests/integration/QUICK_START.md`6. Add or change governed release-promotion workflow inputs, operator-facing promotion metadata, the canonical version file, prerelease feedback intake prompts, artifact publication lineage enforcement, release note or changelog packet composition, or stable-promotion rehearsal summaries through `.github/workflows/create-release.yml`, `.github/workflows/helm-pages.yml`, `.github/workflows/publish-docker.yml`, `.github/workflows/publish-helm-chart.yml`, `.github/workflows/promote-floating-tags.yml`, `.github/workflows/release-dry-run.yml`, `.github/workflows/update-demo-server.yml`, `.github/ISSUE_TEMPLATE/v6_rc_feedback.yml`, `docs/RELEASE_NOTES.md`, `docs/releases/`, `docs/release-control/v6/internal/RELEASE_PROMOTION_POLICY.md`, `docs/release-control/v6/internal/PRE_RELEASE_CHECKLIST.md`, `docs/release-control/v6/internal/RC_TO_GA_REHEARSAL_TEMPLATE.md`, `scripts/check-workflow-dispatch-inputs.py`, `scripts/release_control/render_release_body.py`, `scripts/release_control/record_rc_to_ga_rehearsal.py`, `scripts/release_control/internal/record_rc_to_ga_rehearsal.py`, `scripts/release_control/release_promotion_policy_support.py`, `scripts/trigger-release.sh`, and `scripts/trigger-release-dry-run.sh`That release-promotion boundary also owns prerelease note packet lineage:shipped RC notes must remain historically accurate, the top-leveldiff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex 208d5b005d..315dab466d 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -2716,6 +2716,7 @@"scripts/install-docker.sh","scripts/install.ps1","scripts/install.sh",+ "scripts/lib/hot-dev-runtime.sh","scripts/pulse-auto-update.sh","scripts/release_asset_common.sh","scripts/release_control/internal/record_rc_to_ga_rehearsal.py",@@ -2971,6 +2972,7 @@"scripts/dev-launchd-wrapper.sh","scripts/hot-dev-bg.sh","scripts/hot-dev.sh",+ "scripts/lib/hot-dev-runtime.sh","scripts/toggle-mock.sh","tests/integration/playwright.config.ts","tests/integration/QUICK_START.md",@@ -2984,6 +2986,7 @@"exact_files": ["scripts/release_control/ssh_host_key_policy_test.py","scripts/tests/test-hot-dev-bg.sh",+ "scripts/tests/test-hot-dev-runtime.sh","scripts/tests/test-toggle-mock.sh","tests/integration/tests/16-dev-runtime-recovery.spec.ts"]diff --git a/scripts/hot-dev.sh b/scripts/hot-dev.shindex 5e5172e71d..529896aa18 100755--- a/scripts/hot-dev.sh+++ b/scripts/hot-dev.sh@@ -40,6 +40,8 @@ SCRIPT_MTIME=$(stat -c %Y "${SCRIPT_PATH}" 2>/dev/null || stat -f %m "${SCRIPT_P# shellcheck disable=SC1091source "${SCRIPT_DIR}/lib/hot-dev-auth.sh"+# shellcheck disable=SC1091+source "${SCRIPT_DIR}/lib/hot-dev-runtime.sh"# --- Helper Functions ---@@ -244,6 +246,7 @@ HOT_DEV_BUILD_LOCK="${HOT_DEV_BUILD_LOCK_FILE:-${ROOT_DIR}/tmp/hot-dev.build.locHOT_DEV_WATCHER_STARTUP_GRACE_SECONDS="${HOT_DEV_WATCHER_STARTUP_GRACE_SECONDS:-5}"EMBEDDED_FRONTEND_DIR="${ROOT_DIR}/internal/api/frontend-modern"EMBEDDED_FRONTEND_DIST_DIR="${EMBEDDED_FRONTEND_DIR}/dist"+BACKEND_DEBUG_LOG="${PULSE_BACKEND_LOG_FILE:-/tmp/pulse-debug.log}"# --- Startup Checks ---@@ -280,7 +283,8 @@ kill_port "${PULSE_DEV_API_PORT}"kill_port "${EXTRA_CLEANUP_PORT}"# Truncate debug log-:> /tmp/pulse-debug.log+mkdir -p "$(dirname "${BACKEND_DEBUG_LOG}")"+:> "${BACKEND_DEBUG_LOG}"sleep 2@@ -445,25 +449,31 @@ if [[ ${PRO_BUILD_SUCCESS:-false} == "true" ]]; thenlog_info "Pro audit logging enabled (SQLite storage in ${PULSE_AUDIT_DIR})"fi-LOG_LEVEL="${LOG_LEVEL:-debug}" \-FRONTEND_PORT="${PULSE_DEV_API_PORT:-7655}" \-PORT="${PULSE_DEV_API_PORT:-7655}" \-PULSE_DATA_DIR="${PULSE_DATA_DIR:-}" \-PULSE_ENCRYPTION_KEY="${PULSE_ENCRYPTION_KEY:-}" \-ALLOW_ADMIN_BYPASS="${ALLOW_ADMIN_BYPASS:-1}" \-PULSE_DEV="${PULSE_DEV:-true}" \-PULSE_AUTH_USER="${PULSE_AUTH_USER:-}" \-PULSE_AUTH_PASS="${PULSE_AUTH_PASS:-}" \-ALLOWED_ORIGINS="${ALLOWED_ORIGINS:-}" \-LOG_FILE="/tmp/pulse-debug.log" \-LOG_MAX_SIZE="50" \-./pulse > /dev/null 2>&1 &-BACKEND_PID=$!+STARTED_BACKEND_PID=""+start_backend_process() {+ LOG_LEVEL="${LOG_LEVEL:-debug}" \+ FRONTEND_PORT="${PULSE_DEV_API_PORT:-7655}" \+ PORT="${PULSE_DEV_API_PORT:-7655}" \+ PULSE_DATA_DIR="${PULSE_DATA_DIR:-}" \+ PULSE_ENCRYPTION_KEY="${PULSE_ENCRYPTION_KEY:-}" \+ ALLOW_ADMIN_BYPASS="${ALLOW_ADMIN_BYPASS:-1}" \+ PULSE_DEV="${PULSE_DEV:-true}" \+ PULSE_AUTH_USER="${PULSE_AUTH_USER:-}" \+ PULSE_AUTH_PASS="${PULSE_AUTH_PASS:-}" \+ ALLOWED_ORIGINS="${ALLOWED_ORIGINS:-}" \+ LOG_FILE="${BACKEND_DEBUG_LOG}" \+ LOG_MAX_SIZE="50" \+ ./pulse </dev/null >> "${BACKEND_DEBUG_LOG}" 2>&1 &+ STARTED_BACKEND_PID=$!+}++start_backend_process+BACKEND_PID="${STARTED_BACKEND_PID}"sleep 2if ! kill -0 "${BACKEND_PID}" 2>/dev/null; then- log_error "Backend failed to start!"+ log_error "Backend failed to start! Check ${BACKEND_DEBUG_LOG}"exit 1fi@@ -484,24 +494,12 @@ log_info "Starting backend health monitor..."while true; dosleep 5- PULSE_COUNT=$(pgrep -f "^\./pulse$" 2>/dev/null | wc -l | tr -d ' ')+ PULSE_COUNT="$(hot_dev_pulse_process_count)"if [[ "$PULSE_COUNT" -eq 0 ]]; thenlog_warn "⚠️ Pulse died unexpectedly, restarting..."- LOG_LEVEL="${LOG_LEVEL:-debug}" \- FRONTEND_PORT="${PULSE_DEV_API_PORT:-7655}" \- PORT="${PULSE_DEV_API_PORT:-7655}" \- PULSE_DATA_DIR="${PULSE_DATA_DIR:-}" \- PULSE_ENCRYPTION_KEY="${PULSE_ENCRYPTION_KEY:-}" \- ALLOW_ADMIN_BYPASS="${ALLOW_ADMIN_BYPASS:-1}" \- PULSE_DEV="${PULSE_DEV:-true}" \- PULSE_AUTH_USER="${PULSE_AUTH_USER:-}" \- PULSE_AUTH_PASS="${PULSE_AUTH_PASS:-}" \- ALLOWED_ORIGINS="${ALLOWED_ORIGINS:-}" \- LOG_FILE="/tmp/pulse-debug.log" \- LOG_MAX_SIZE="50" \- ./pulse </dev/null > /dev/null 2>&1 &- NEW_PID=$!+ start_backend_process+ NEW_PID="${STARTED_BACKEND_PID}"sleep 2if kill -0 "$NEW_PID" 2>/dev/null; thenlog_info "✓ Backend auto-restarted (PID: $NEW_PID)"@@ -513,20 +511,8 @@ log_info "Starting backend health monitor..."log_error "⚠️ Multiple Pulse processes detected ($PULSE_COUNT), killing all and restarting..."pkill -9 -f "^\./pulse$" 2>/dev/null || truesleep 2- LOG_LEVEL="${LOG_LEVEL:-debug}" \- FRONTEND_PORT="${PULSE_DEV_API_PORT:-7655}" \- PORT="${PULSE_DEV_API_PORT:-7655}" \- PULSE_DATA_DIR="${PULSE_DATA_DIR:-}" \- PULSE_ENCRYPTION_KEY="${PULSE_ENCRYPTION_KEY:-}" \- ALLOW_ADMIN_BYPASS="${ALLOW_ADMIN_BYPASS:-1}" \- PULSE_DEV="${PULSE_DEV:-true}" \- PULSE_AUTH_USER="${PULSE_AUTH_USER:-}" \- PULSE_AUTH_PASS="${PULSE_AUTH_PASS:-}" \- ALLOWED_ORIGINS="${ALLOWED_ORIGINS:-}" \- LOG_FILE="/tmp/pulse-debug.log" \- LOG_MAX_SIZE="50" \- ./pulse </dev/null > /dev/null 2>&1 &- NEW_PID=$!+ start_backend_process+ NEW_PID="${STARTED_BACKEND_PID}"sleep 2if kill -0 "$NEW_PID" 2>/dev/null; thenlog_info "✓ Backend restarted after killing duplicates (PID: $NEW_PID)"@@ -541,20 +527,8 @@ log_info "Starting backend health monitor..."log_error "⚠️ Killing unresponsive Pulse and restarting..."pkill -9 -f "^\./pulse$" 2>/dev/null || truesleep 2- LOG_LEVEL="${LOG_LEVEL:-debug}" \- FRONTEND_PORT="${PULSE_DEV_API_PORT:-7655}" \- PORT="${PULSE_DEV_API_PORT:-7655}" \- PULSE_DATA_DIR="${PULSE_DATA_DIR:-}" \- PULSE_ENCRYPTION_KEY="${PULSE_ENCRYPTION_KEY:-}" \- ALLOW_ADMIN_BYPASS="${ALLOW_ADMIN_BYPASS:-1}" \- PULSE_DEV="${PULSE_DEV:-true}" \- PULSE_AUTH_USER="${PULSE_AUTH_USER:-}" \- PULSE_AUTH_PASS="${PULSE_AUTH_PASS:-}" \- ALLOWED_ORIGINS="${ALLOWED_ORIGINS:-}" \- LOG_FILE="/tmp/pulse-debug.log" \- LOG_MAX_SIZE="50" \- ./pulse </dev/null > /dev/null 2>&1 &- NEW_PID=$!+ start_backend_process+ NEW_PID="${STARTED_BACKEND_PID}"sleep 2if kill -0 "$NEW_PID" 2>/dev/null; thenlog_info "✓ Backend restarted after unresponsive state (PID: $NEW_PID)"@@ -704,31 +678,19 @@ log_info "Starting backend file watcher..."# Close inherited stdin (</dev/null) to prevent pipe fd leaks when# this function is called from inside a piped while-read loop.- LOG_LEVEL="${LOG_LEVEL:-debug}" \- FRONTEND_PORT="${PULSE_DEV_API_PORT:-7655}" \- PORT="${PULSE_DEV_API_PORT:-7655}" \- PULSE_DATA_DIR="${PULSE_DATA_DIR:-}" \- PULSE_ENCRYPTION_KEY="${PULSE_ENCRYPTION_KEY:-}" \- ALLOW_ADMIN_BYPASS="${ALLOW_ADMIN_BYPASS:-1}" \- PULSE_DEV="${PULSE_DEV:-true}" \- PULSE_AUTH_USER="${PULSE_AUTH_USER:-}" \- PULSE_AUTH_PASS="${PULSE_AUTH_PASS:-}" \- ALLOWED_ORIGINS="${ALLOWED_ORIGINS:-}" \- LOG_FILE="/tmp/pulse-debug.log" \- LOG_MAX_SIZE="50" \- ./pulse </dev/null > /dev/null 2>&1 &- NEW_PID=$!+ start_backend_process+ NEW_PID="${STARTED_BACKEND_PID}"sleep 1# Verify exactly one process is running- PULSE_COUNT=$(pgrep -f "^\./pulse$" 2>/dev/null | wc -l | tr -d ' ')+ PULSE_COUNT="$(hot_dev_pulse_process_count)"if [[ "$PULSE_COUNT" -eq 1 ]] && kill -0 "$NEW_PID" 2>/dev/null; thenlog_info "✓ Backend restarted (PID: $NEW_PID)"elif [[ "$PULSE_COUNT" -gt 1 ]]; thenlog_error "✗ Multiple processes after restart ($PULSE_COUNT) - killing all"pkill -9 -f "^\./pulse$" 2>/dev/null || trueelse- log_error "✗ Backend failed to start! Check /tmp/pulse-debug.log"+ log_error "✗ Backend failed to start! Check ${BACKEND_DEBUG_LOG}"fi}diff --git a/scripts/lib/hot-dev-runtime.sh b/scripts/lib/hot-dev-runtime.shnew file mode 100644index 0000000000..e241c2a8fd--- /dev/null+++ b/scripts/lib/hot-dev-runtime.sh@@ -0,0 +1,21 @@+#!/usr/bin/env bash++# Shared helpers for the managed local Pulse development runtime.++hot_dev_pulse_process_count() {+ local pattern="${1:-^\./pulse$}"+ local count=0+ local pid++ if ! command -v pgrep >/dev/null 2>&1; then+ printf '0\n'+ return 0+ fi++ while IFS= read -r pid; do+ [[ -n "${pid}" ]] || continue+ count=$((count + 1))+ done < <(pgrep -f "${pattern}" 2>/dev/null || true)++ printf '%s\n' "${count}"+}diff --git a/scripts/tests/test-hot-dev-runtime.sh b/scripts/tests/test-hot-dev-runtime.shnew file mode 100755index 0000000000..96d7404a28--- /dev/null+++ b/scripts/tests/test-hot-dev-runtime.sh@@ -0,0 +1,141 @@+#!/usr/bin/env bash++set -euo pipefail++ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"+HOT_DEV_RUNTIME_LIB="${ROOT_DIR}/scripts/lib/hot-dev-runtime.sh"+HOT_DEV="${ROOT_DIR}/scripts/hot-dev.sh"++if [[ ! -f "${HOT_DEV_RUNTIME_LIB}" ]]; then+ echo "hot-dev-runtime.sh not found at ${HOT_DEV_RUNTIME_LIB}" >&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+}++assert_not_contains() {+ local desc="$1"+ local haystack="$2"+ local needle="$3"++ if [[ "${haystack}" == *"${needle}"* ]]; then+ echo "[FAIL] ${desc}" >&2+ echo "Did not expect to find: ${needle}" >&2+ ((failures++))+ else+ echo "[PASS] ${desc}"+ fi+}++make_temp_dir() {+ local dir+ dir="$(mktemp -d)"+ temp_dirs+=("${dir}")+ printf "%s\n" "${dir}"+}++test_pulse_process_count_handles_zero_matches_under_pipefail() {+ local test_dir fake_bin output+ test_dir="$(make_temp_dir)"+ fake_bin="${test_dir}/bin"+ mkdir -p "${fake_bin}"++ cat > "${fake_bin}/pgrep" <<'EOF'+#!/usr/bin/env bash+exit 1+EOF+ chmod +x "${fake_bin}/pgrep"++ output="$(+ PATH="${fake_bin}:$PATH" \+ HOT_DEV_RUNTIME_LIB="${HOT_DEV_RUNTIME_LIB}" \+ bash -c '+ set -euo pipefail+ source "${HOT_DEV_RUNTIME_LIB}"+ printf "count=%s\n" "$(hot_dev_pulse_process_count)"+ printf "survived=yes\n"+ '+ )"++ assert_contains "zero process count returns zero" "${output}" "count=0"+ assert_contains "zero process count does not trip errexit" "${output}" "survived=yes"+}++test_pulse_process_count_counts_matching_processes() {+ local test_dir fake_bin output+ test_dir="$(make_temp_dir)"+ fake_bin="${test_dir}/bin"+ mkdir -p "${fake_bin}"++ cat > "${fake_bin}/pgrep" <<'EOF'+#!/usr/bin/env bash+printf '111\n222\n'+EOF+ chmod +x "${fake_bin}/pgrep"++ output="$(+ PATH="${fake_bin}:$PATH" \+ HOT_DEV_RUNTIME_LIB="${HOT_DEV_RUNTIME_LIB}" \+ bash -c '+ set -euo pipefail+ source "${HOT_DEV_RUNTIME_LIB}"+ printf "count=%s\n" "$(hot_dev_pulse_process_count)"+ '+ )"++ assert_contains "process count counts pgrep output lines" "${output}" "count=2"+}++test_hot_dev_uses_resilient_backend_process_count() {+ local output+ output="$(sed -n '1,760p' "${HOT_DEV}")"++ assert_contains "hot-dev sources runtime helper" "${output}" "source \"\${SCRIPT_DIR}/lib/hot-dev-runtime.sh\""+ assert_contains "health monitor uses resilient process counter" "${output}" "PULSE_COUNT=\"\$(hot_dev_pulse_process_count)\""+ assert_not_contains "hot-dev no longer counts backend processes through a pipefail-sensitive pgrep pipeline" "${output}" "PULSE_COUNT=\$(pgrep -f \"^\\./pulse$\""+}++test_hot_dev_keeps_backend_launch_errors_in_debug_log() {+ local output+ output="$(sed -n '1,760p' "${HOT_DEV}")"++ assert_contains "hot-dev exposes backend debug log override" "${output}" "BACKEND_DEBUG_LOG=\"\${PULSE_BACKEND_LOG_FILE:-/tmp/pulse-debug.log}\""+ assert_contains "backend launch stderr is appended to the debug log" "${output}" ">> \"\${BACKEND_DEBUG_LOG}\" 2>&1"+ assert_contains "backend LOG_FILE follows debug log override" "${output}" "LOG_FILE=\"\${BACKEND_DEBUG_LOG}\""+}++source "${HOT_DEV_RUNTIME_LIB}"+test_pulse_process_count_handles_zero_matches_under_pipefail+test_pulse_process_count_counts_matching_processes+test_hot_dev_uses_resilient_backend_process_count+test_hot_dev_keeps_backend_launch_errors_in_debug_log++if (( failures > 0 )); then+ echo "FAIL: ${failures} hot-dev runtime assertions failed" >&2+ exit 1+fi++echo "PASS: hot-dev runtime contract checks passed"