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.

Make dev-check use managed runtime status

rcourtman4212a5ad0efa
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index acaa03f745..6427221341 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -188,6 +188,12 @@ must route operators back to the managed runtime entrypoint before falling back
to process-killing folklore, otherwise the repo keeps reintroducing the same
split-ownership `5173` versus `7655` confusion through secondary entry
surfaces.
+That same `scripts/dev-check.sh` helper must treat `hot-dev-bg status` as the
+canonical dev diagnosis surface instead of re-deriving its own competing
+frontend-versus-backend health story from ad hoc curls and process scans. Any
+secondary checks it adds should be clearly subordinate to the managed runtime
+ownership and health report, and unhealthy runtime guidance must point back to
+the repo-root managed controls such as `npm run dev` or `npm run dev:restart`.
When the frontend workspace exposes managed runtime wrappers, they must stay in
operational parity with the repo-root entry surface for the canonical controls:
start, status, logs, stop, restart, managed backend restart, verification, and
diff --git a/scripts/dev-check.sh b/scripts/dev-check.sh
index 056a9de9cd..5d89b270d6 100755
--- a/scripts/dev-check.sh
+++ b/scripts/dev-check.sh
@@ -1,101 +1,145 @@
#!/bin/bash
-# Quick dev environment health check
-# Run this before debugging frontend issues!
+# Quick dev environment health check.
#
# Usage:
# ./scripts/dev-check.sh # Check and report
-# ./scripts/dev-check.sh --kill # Kill all dev processes
+# ./scripts/dev-check.sh --kill # Stop managed runtime, then clean up residual legacy processes
+
+set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
-# Handle --kill flag
-if [[ "${1:-}" == "--kill" ]]; then
- echo "Stopping all dev processes..."
- if [[ -x "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hot-dev-bg.sh" ]]; then
- "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/hot-dev-bg.sh" stop >/dev/null 2>&1 || true
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
+HOT_DEV_BG_PATH="${HOT_DEV_BG_PATH:-${SCRIPT_DIR}/hot-dev-bg.sh}"
+HOT_DEV_BG_LOG_FILE="${HOT_DEV_BG_LOG_FILE:-${ROOT_DIR}/tmp/hot-dev.bg.log}"
+FRONTEND_URL="${PULSE_DEV_CHECK_FRONTEND_URL:-http://127.0.0.1:5173}"
+BACKEND_URL="${PULSE_DEV_CHECK_BACKEND_URL:-http://127.0.0.1:7655}"
+SKIP_AUXILIARY_CHECKS="${PULSE_DEV_CHECK_SKIP_AUXILIARY_CHECKS:-false}"
+
+managed_status() {
+ if [[ -x "${HOT_DEV_BG_PATH}" ]]; then
+ "${HOT_DEV_BG_PATH}" status 2>&1 || true
+ return
fi
+
+ echo "[hot-dev-bg] Not available at ${HOT_DEV_BG_PATH}"
+}
+
+show_managed_guidance() {
+ local status_output="$1"
+
+ if [[ "${status_output}" == *"Runtime summary: frontend shell, proxy, and backend are healthy."* ]]; then
+ echo "Managed guidance: use ${FRONTEND_URL} in the browser."
+ return
+ fi
+
+ if [[ "${status_output}" == *"[hot-dev-bg] Not running"* ]]; then
+ echo "Managed guidance: cd ${ROOT_DIR} && npm run dev"
+ return
+ fi
+
+ echo "Managed guidance: cd ${ROOT_DIR} && npm run dev:restart"
+}
+
+stop_managed_runtime() {
+ if [[ -x "${HOT_DEV_BG_PATH}" ]]; then
+ "${HOT_DEV_BG_PATH}" stop >/dev/null 2>&1 || true
+ fi
+}
+
+kill_legacy_processes() {
pkill -9 -f "bin/pulse$" 2>/dev/null || true
pkill -9 -f "^\./pulse$" 2>/dev/null || true
pkill -f "node.*vite" 2>/dev/null || true
pkill -f "watch-snapshot.sh" 2>/dev/null || true
- sleep 2
- echo -e "${GREEN}✓${NC} All dev processes stopped"
- exit 0
-fi
-
-echo "=== Pulse Dev Environment Check ==="
-echo ""
-
-# Check for duplicate Pulse processes (CRITICAL!)
-# Count both installed binary and dev binary patterns
-# Note: macOS pgrep doesn't support -c, so we use wc -l
-PULSE_COUNT_BIN=$(pgrep -f "bin/pulse$" 2>/dev/null | wc -l | tr -d ' ')
-PULSE_COUNT_DEV=$(pgrep -f "^\./pulse$" 2>/dev/null | wc -l | tr -d ' ')
-PULSE_COUNT=$(( ${PULSE_COUNT_BIN:-0} + ${PULSE_COUNT_DEV:-0} ))
-echo -n "Pulse processes: "
-if [[ $PULSE_COUNT -eq 0 ]]; then
- echo -e "${YELLOW}⚠ None running${NC}"
-elif [[ $PULSE_COUNT -eq 1 ]]; then
- PULSE_PID=$(pgrep -f "bin/pulse$" 2>/dev/null || pgrep -f "^\./pulse$" 2>/dev/null || echo "?")
- echo -e "${GREEN}✓ 1 running (PID: $PULSE_PID)${NC}"
-else
- echo -e "${RED}✗ MULTIPLE RUNNING ($PULSE_COUNT)! This causes database locks!${NC}"
- pgrep -af "pulse$" | grep -E "(bin/pulse|^\./pulse)" | head -5
- echo -e " ${YELLOW}Fix: ./scripts/dev-check.sh --kill${NC}"
-fi
-
-# Check Pulse backend connectivity
-echo -n "Pulse backend (port 7655): "
-if curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:7655/api/health 2>/dev/null | grep -q "200\|401\|403"; then
- echo -e "${GREEN}✓ Responding${NC}"
-elif [[ "$(uname -s)" == "Linux" ]] && systemctl is-active --quiet pulse 2>/dev/null; then
- echo -e "${YELLOW}⚠ Service running but not responding${NC}"
-else
- echo -e "${RED}✗ NOT RESPONDING${NC}"
-fi
-
-# Check frontend shell
-echo -n "Frontend shell (port 5173): "
-if curl -s -o /dev/null http://127.0.0.1:5173/ 2>/dev/null; then
- echo -e "${GREEN}✓ Running${NC}"
-else
- echo -e "${RED}✗ NOT RUNNING${NC}"
- echo " Fix: cd \${PULSE_REPOS_DIR:-\$HOME/pulse/repos}/pulse && npm run dev"
-fi
-
-# Check AI status
-echo -n "AI service: "
-AI_STATUS=$(curl -s -u admin:admin http://127.0.0.1:7655/api/ai/status 2>/dev/null | jq -r '.running // false')
-if [[ "$AI_STATUS" == "true" ]]; then
- echo -e "${GREEN}✓ Running (direct integration)${NC}"
-else
- echo -e "${YELLOW}⚠ Not running (enable in settings)${NC}"
-fi
-
-# Check snapshot watcher
-echo -n "Snapshot watcher: "
-SNAPSHOT_PID=$(pgrep -f "watch-snapshot.sh" 2>/dev/null | head -1)
-if [[ -n "$SNAPSHOT_PID" ]]; then
- SNAPSHOT_COUNT=$(git -C ~/.pulse-snapshots rev-list --count HEAD 2>/dev/null || echo 0)
- echo -e "${GREEN}✓ Running (PID: $SNAPSHOT_PID, $SNAPSHOT_COUNT snapshots)${NC}"
-else
- echo -e "${YELLOW}⚠ Not running (optional - protects against accidental file loss)${NC}"
- echo " Start: ./scripts/watch-snapshot.sh &"
-fi
-
-# Show recent errors
-echo ""
-echo "=== Recent Pulse Errors (last 5) ==="
-if [[ "$(uname -s)" == "Darwin" ]]; then
- # macOS: check the debug log
- grep -i "error\|fatal\|panic" /tmp/pulse-debug.log 2>/dev/null | tail -5 || echo "None found"
-else
- # Linux: use journalctl
- journalctl -u pulse-dev --no-pager -n 20 2>/dev/null | grep -i "error\|fatal\|panic" | tail -5 || echo "None found"
-fi
-
-echo ""
-echo "Done."
+}
+
+show_ai_status() {
+ local frontend_ai_url backend_ai_url ai_response ai_status
+ frontend_ai_url="${FRONTEND_URL}/api/ai/status"
+ backend_ai_url="${BACKEND_URL}/api/ai/status"
+
+ echo -n "AI service: "
+ ai_response="$(curl -s -u admin:admin "${frontend_ai_url}" 2>/dev/null || curl -s -u admin:admin "${backend_ai_url}" 2>/dev/null || true)"
+ if [[ -n "${ai_response}" ]] && command -v jq >/dev/null 2>&1; then
+ ai_status="$(printf '%s' "${ai_response}" | jq -r '.running // false' 2>/dev/null || echo "false")"
+ else
+ ai_status="false"
+ fi
+
+ if [[ "${ai_status}" == "true" ]]; then
+ echo -e "${GREEN}✓ Running (direct integration)${NC}"
+ else
+ echo -e "${YELLOW}⚠ Not running (enable in settings)${NC}"
+ fi
+}
+
+show_snapshot_status() {
+ local snapshot_pid snapshot_count
+ echo -n "Snapshot watcher: "
+ snapshot_pid="$(pgrep -f "watch-snapshot.sh" 2>/dev/null | head -1 || true)"
+ if [[ -n "${snapshot_pid}" ]]; then
+ snapshot_count="$(git -C ~/.pulse-snapshots rev-list --count HEAD 2>/dev/null || echo 0)"
+ echo -e "${GREEN}✓ Running (PID: ${snapshot_pid}, ${snapshot_count} snapshots)${NC}"
+ else
+ echo -e "${YELLOW}⚠ Not running (optional - protects against accidental file loss)${NC}"
+ echo " Start: ./scripts/watch-snapshot.sh &"
+ fi
+}
+
+show_recent_errors() {
+ echo ""
+ echo "=== Recent Pulse Errors (last 5) ==="
+
+ if [[ -f "${HOT_DEV_BG_LOG_FILE}" ]]; then
+ grep -i "error\|fatal\|panic" "${HOT_DEV_BG_LOG_FILE}" 2>/dev/null | tail -5 || echo "None found"
+ return
+ fi
+
+ if [[ "$(uname -s)" == "Darwin" ]]; then
+ grep -i "error\|fatal\|panic" /tmp/pulse-debug.log 2>/dev/null | tail -5 || echo "None found"
+ else
+ journalctl -u pulse-dev --no-pager -n 20 2>/dev/null | grep -i "error\|fatal\|panic" | tail -5 || echo "None found"
+ fi
+}
+
+main() {
+ local status_output
+
+ if [[ "${1:-}" == "--kill" ]]; then
+ echo "Stopping managed dev runtime and cleaning residual legacy processes..."
+ stop_managed_runtime
+ kill_legacy_processes
+ sleep 2
+ echo -e "${GREEN}✓${NC} Managed runtime stop requested and residual legacy processes cleaned up"
+ exit 0
+ fi
+
+ echo "=== Pulse Dev Environment Check ==="
+ echo ""
+ echo "=== Managed Runtime Status ==="
+ status_output="$(managed_status)"
+ printf '%s\n' "${status_output}"
+ echo ""
+ show_managed_guidance "${status_output}"
+
+ if [[ "${SKIP_AUXILIARY_CHECKS}" == "true" ]]; then
+ echo ""
+ echo "Done."
+ exit 0
+ fi
+
+ echo ""
+ show_ai_status
+ show_snapshot_status
+ show_recent_errors
+
+ echo ""
+ echo "Done."
+}
+
+main "$@"
diff --git a/scripts/tests/test-hot-dev-bg.sh b/scripts/tests/test-hot-dev-bg.sh
index 0a245687ed..7840f8e314 100755
--- a/scripts/tests/test-hot-dev-bg.sh
+++ b/scripts/tests/test-hot-dev-bg.sh
@@ -7,6 +7,7 @@ set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
HOT_DEV_BG="${ROOT_DIR}/scripts/hot-dev-bg.sh"
CLEAN_MOCK_ALERTS="${ROOT_DIR}/scripts/clean-mock-alerts.sh"
+DEV_CHECK="${ROOT_DIR}/scripts/dev-check.sh"
PACKAGE_JSON="${ROOT_DIR}/package.json"
FRONTEND_PACKAGE_JSON="${ROOT_DIR}/frontend-modern/package.json"
DEV_LAUNCHD_WRAPPER="${ROOT_DIR}/scripts/dev-launchd-wrapper.sh"
@@ -365,6 +366,41 @@ PY
assert_contains "clean-mock-alerts leaves no mock alerts" "${mock_count}" "0"
}
+test_dev_check_uses_managed_runtime_status() {
+ local test_dir fake_hot_dev_bg output
+ test_dir="$(mktemp -d)"
+ temp_dirs+=("${test_dir}")
+ fake_hot_dev_bg="${test_dir}/hot-dev-bg.sh"
+
+ cat > "${fake_hot_dev_bg}" <<'EOF'
+#!/usr/bin/env bash
+set -euo pipefail
+case "${1:-}" in
+ status)
+ echo "[hot-dev-bg] Running (pid: 4242)"
+ echo "[hot-dev-bg] Browser entrypoint: http://127.0.0.1:5173"
+ echo "[hot-dev-bg] Runtime summary: frontend shell is up, but the backend health endpoint is unavailable."
+ ;;
+ *)
+ echo "unexpected command: $*" >&2
+ exit 1
+ ;;
+esac
+EOF
+ chmod +x "${fake_hot_dev_bg}"
+
+ output="$(
+ PULSE_DEV_CHECK_SKIP_AUXILIARY_CHECKS=true \
+ HOT_DEV_BG_PATH="${fake_hot_dev_bg}" \
+ "${DEV_CHECK}"
+ )"
+
+ assert_contains "dev-check prints managed runtime heading" "${output}" "=== Managed Runtime Status ==="
+ assert_contains "dev-check relays hot-dev-bg status" "${output}" "[hot-dev-bg] Running (pid: 4242)"
+ assert_contains "dev-check relays runtime summary" "${output}" "frontend shell is up, but the backend health endpoint is unavailable"
+ assert_contains "dev-check recommends managed restart for unhealthy runtime" "${output}" "npm run dev:restart"
+}
+
test_backend_restart_requires_managed_runtime() {
local frontend_port backend_port output
local state_dir
@@ -445,6 +481,7 @@ main() {
test_root_package_exposes_managed_runtime_entrypoints
test_frontend_package_exposes_managed_runtime_entrypoints
test_clean_mock_alerts_prefers_managed_runtime
+ test_dev_check_uses_managed_runtime_status
test_backend_restart_requires_managed_runtime
test_status_without_runtime
test_detects_unmanaged_listeners