Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Add one-command dev runtime verify

rcourtman530b2f215e80
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index a4806beee8..b2acaffbce 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -161,6 +161,12 @@ browser runtime, cover both stream-only reconnect degradation and full backend
loss, bounce the real backend through the launcher contract when needed, and
prove that the shell degrades and recovers through the proxy instead of
relying on backend-only API checks that miss browser/runtime drift.
+That same launcher boundary now also owns the one-command verification entry
+point for that proof. `./scripts/hot-dev-bg.sh verify` must prepare a coherent
+managed runtime, run the canonical browser recovery proof with the managed dev
+credentials and browser entrypoint defaults, and fail with ownership or health
+diagnostics instead of leaving operators to remember the exact Playwright
+command and env combination by hand.
That shared `scripts/install.sh` boundary must also keep one canonical service
argument builder for the runtime flags it persists. Token-bearing install
paths, token-file systemd paths, wrapper-script launches, and later service
diff --git a/scripts/hot-dev-bg.sh b/scripts/hot-dev-bg.sh
index 1f26e49ee8..e315099961 100755
--- a/scripts/hot-dev-bg.sh
+++ b/scripts/hot-dev-bg.sh
@@ -7,6 +7,7 @@
# ./scripts/hot-dev-bg.sh stop
# ./scripts/hot-dev-bg.sh restart
# ./scripts/hot-dev-bg.sh backend-restart
+# ./scripts/hot-dev-bg.sh verify [--takeover]
# ./scripts/hot-dev-bg.sh status
# ./scripts/hot-dev-bg.sh logs
@@ -169,6 +170,10 @@ is_running() {
kill -0 "${pid}" 2>/dev/null
}
+managed_session_pid() {
+ cat "${PID_FILE}" 2>/dev/null || true
+}
+
describe_listener() {
local port="$1"
local session_pid="${2:-}"
@@ -543,7 +548,7 @@ restart_backend_bg() {
fi
local session_pid backend_pid next_backend_pid restart_sentinel
- session_pid="$(cat "${PID_FILE}")"
+ session_pid="$(managed_session_pid)"
backend_pid="$(first_managed_listener_pid "${PULSE_DEV_API_PORT}" "${session_pid}" || true)"
restart_sentinel="${ROOT_DIR}/tmp/hot-dev.restart"
@@ -590,6 +595,80 @@ restart_backend_bg() {
log "Managed backend recovered and is healthy on port ${PULSE_DEV_API_PORT}"
}
+runtime_healthy() {
+ local frontend_code proxy_code backend_code managed_pid
+ managed_pid="$(managed_session_pid)"
+
+ [[ -n "${managed_pid}" ]] || return 1
+ port_has_managed_listener "${FRONTEND_DEV_PORT}" "${managed_pid}" || return 1
+ port_has_managed_listener "${PULSE_DEV_API_PORT}" "${managed_pid}" || return 1
+
+ frontend_code="$(http_status_code "http://127.0.0.1:${FRONTEND_DEV_PORT}/")"
+ proxy_code="$(http_status_code "http://127.0.0.1:${FRONTEND_DEV_PORT}/api/health")"
+ backend_code="$(http_status_code "http://127.0.0.1:${PULSE_DEV_API_PORT}/api/health")"
+
+ http_status_ok "${frontend_code}" && http_status_ok "${proxy_code}" && http_status_ok "${backend_code}"
+}
+
+run_verify_proof_command() {
+ local verify_command integration_dir
+ integration_dir="${ROOT_DIR}/tests/integration"
+ verify_command="${HOT_DEV_BG_VERIFY_COMMAND:-}"
+
+ if [[ -z "${verify_command}" ]]; then
+ (
+ cd "${integration_dir}"
+ PULSE_E2E_USE_HOT_DEV=1 \
+ PULSE_E2E_USERNAME="${PULSE_E2E_USERNAME:-admin}" \
+ PULSE_E2E_PASSWORD="${PULSE_E2E_PASSWORD:-admin}" \
+ npm test -- tests/16-dev-runtime-recovery.spec.ts --project=chromium
+ )
+ return
+ fi
+
+ (
+ cd "${ROOT_DIR}"
+ PULSE_E2E_USE_HOT_DEV=1 \
+ PULSE_E2E_USERNAME="${PULSE_E2E_USERNAME:-admin}" \
+ PULSE_E2E_PASSWORD="${PULSE_E2E_PASSWORD:-admin}" \
+ bash -lc "${verify_command}"
+ )
+}
+
+verify_bg() {
+ local takeover="${1:-false}"
+ local managed_pid
+
+ require_python
+
+ if ! is_running; then
+ log "Managed runtime is not running. Starting it before verification..."
+ start_bg "${takeover}"
+ else
+ managed_pid="$(managed_session_pid)"
+ if [[ -n "${managed_pid}" ]] && has_unmanaged_listeners "${managed_pid}"; then
+ if [[ "${takeover}" != "true" ]]; then
+ fail "Managed runtime has split ownership. Rerun with: ./scripts/hot-dev-bg.sh verify --takeover"
+ fi
+ log "Managed runtime has split ownership. Reclaiming ports before verification..."
+ stop_bg
+ start_bg "${takeover}"
+ elif ! runtime_healthy; then
+ log "Managed runtime is unhealthy. Restarting it before verification..."
+ stop_bg
+ start_bg "${takeover}"
+ fi
+ fi
+
+ if ! runtime_healthy; then
+ status_bg
+ fail "Managed runtime is not healthy enough to run browser verification"
+ fi
+
+ log "Running managed dev-runtime browser verification proof..."
+ run_verify_proof_command
+}
+
usage() {
cat <<EOF
Usage: $(basename "$0") <command>
@@ -599,6 +678,7 @@ Commands:
stop
restart
backend-restart
+ verify [--takeover]
status
logs
EOF
@@ -609,7 +689,7 @@ parse_takeover_flag() {
local flag="${2:-}"
case "${command}" in
- start|restart)
+ start|restart|verify)
if [[ -z "${flag}" ]]; then
printf "false\n"
return 0
@@ -651,6 +731,7 @@ main() {
start_bg "${takeover}"
;;
backend-restart) restart_backend_bg ;;
+ verify) verify_bg "${takeover}" ;;
status) status_bg ;;
logs) logs_bg ;;
*) usage; exit 1 ;;
diff --git a/scripts/tests/test-hot-dev-bg.sh b/scripts/tests/test-hot-dev-bg.sh
index 3e51216c45..295808fa60 100755
--- a/scripts/tests/test-hot-dev-bg.sh
+++ b/scripts/tests/test-hot-dev-bg.sh
@@ -103,6 +103,7 @@ test_cli_parses_takeover_flag() {
source "${HOT_DEV_BG_PATH}"
printf "start=%s\n" "$(parse_takeover_flag start --takeover)"
printf "restart=%s\n" "$(parse_takeover_flag restart --takeover)"
+ printf "verify=%s\n" "$(parse_takeover_flag verify --takeover)"
printf "backend_restart=%s\n" "$(parse_takeover_flag backend-restart)"
printf "plain=%s\n" "$(parse_takeover_flag start)"
if parse_takeover_flag status --takeover >/tmp/hot-dev-bg.invalid 2>&1; then
@@ -115,11 +116,33 @@ test_cli_parses_takeover_flag() {
assert_contains "takeover parsing enables start" "${output}" "start=true"
assert_contains "takeover parsing enables restart" "${output}" "restart=true"
+ assert_contains "takeover parsing enables verify" "${output}" "verify=true"
assert_contains "backend restart remains flagless" "${output}" "backend_restart=false"
assert_contains "start without flag stays false" "${output}" "plain=false"
assert_contains "unexpected status flag is rejected" "${output}" "invalid=rejected"
}
+test_verify_command_injects_managed_runtime_env() {
+ local output
+ output="$(
+ HOT_DEV_BG_PATH="${HOT_DEV_BG}" \
+ bash -lc '
+ source "${HOT_DEV_BG_PATH}"
+ HOT_DEV_BG_VERIFY_COMMAND="python3 - <<'\''PY'\''
+import os
+print(f\"mode={os.environ.get('\''PULSE_E2E_USE_HOT_DEV'\'')}\")
+print(f\"username={os.environ.get('\''PULSE_E2E_USERNAME'\'')}\")
+print(f\"password={os.environ.get('\''PULSE_E2E_PASSWORD'\'')}\")
+PY"
+ run_verify_proof_command
+ '
+ )"
+
+ assert_contains "verify proof forces managed hot-dev mode" "${output}" "mode=1"
+ assert_contains "verify proof defaults username" "${output}" "username=admin"
+ assert_contains "verify proof defaults password" "${output}" "password=admin"
+}
+
test_backend_restart_requires_managed_runtime() {
local frontend_port backend_port output
local state_dir
@@ -194,6 +217,7 @@ test_detects_unmanaged_listeners() {
main() {
test_cli_parses_takeover_flag
+ test_verify_command_injects_managed_runtime_env
test_backend_restart_requires_managed_runtime
test_status_without_runtime
test_detects_unmanaged_listeners