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.

chore: update dev scripts and mock configuration

rcourtman66e846019663
diff --git a/mock.env b/mock.env
index 230e7bd35b..5d34edd807 100644
--- a/mock.env
+++ b/mock.env
@@ -1,5 +1,5 @@
# Mock Mode Configuration
-PULSE_MOCK_MODE=true
+PULSE_MOCK_MODE=false
PULSE_MOCK_NODES=7
PULSE_MOCK_VMS_PER_NODE=5
PULSE_MOCK_LXCS_PER_NODE=8
@@ -7,3 +7,4 @@ PULSE_MOCK_DOCKER_HOSTS=3
PULSE_MOCK_DOCKER_CONTAINERS=12
PULSE_MOCK_RANDOM_METRICS=true
PULSE_MOCK_STOPPED_PERCENT=20
+PULSE_LICENSE_PUBLIC_KEY="OzbVzmg+TaSGt0eWzDVpn0QkqhOzJqUbOFvSF3AmuRU="
diff --git a/scripts/hot-dev.sh b/scripts/hot-dev.sh
index 8e6ecbe220..58f973a97e 100755
--- a/scripts/hot-dev.sh
+++ b/scripts/hot-dev.sh
@@ -409,11 +409,14 @@ fi
# --- Backend Health Monitor ---
# Restarts Pulse if it dies unexpectedly (not from file watcher rebuild)
+# IMPORTANT: Enforces single-instance - kills duplicates if found
log_info "Starting backend health monitor..."
(
while true; do
sleep 10
- if ! pgrep -f "^\./pulse$" > /dev/null 2>&1; then
+ PULSE_COUNT=$(pgrep -f "^\./pulse$" 2>/dev/null | wc -l | tr -d ' ')
+
+ if [[ "$PULSE_COUNT" -eq 0 ]]; then
log_warn "⚠️ Pulse died unexpectedly, restarting..."
LOG_LEVEL=debug \
FRONTEND_PORT="${PULSE_DEV_API_PORT:-7655}" \
@@ -433,6 +436,28 @@ log_info "Starting backend health monitor..."
else
log_error "✗ Backend failed to auto-restart!"
fi
+ elif [[ "$PULSE_COUNT" -gt 1 ]]; then
+ log_error "⚠️ Multiple Pulse processes detected ($PULSE_COUNT), killing all and restarting..."
+ pkill -9 -f "^\./pulse$" 2>/dev/null || true
+ sleep 2
+ 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:-}" \
+ ./pulse >> /tmp/pulse-debug.log 2>&1 &
+ NEW_PID=$!
+ sleep 2
+ if kill -0 "$NEW_PID" 2>/dev/null; then
+ log_info "✓ Backend restarted after killing duplicates (PID: $NEW_PID)"
+ else
+ log_error "✗ Backend failed to restart after killing duplicates!"
+ fi
fi
done
) &
@@ -446,15 +471,13 @@ log_info "Starting backend file watcher..."
restart_backend() {
log_info "Restarting backend..."
-
- OLD_PID=$(pgrep -f "^\./pulse$" || true)
- if [[ -n "$OLD_PID" ]]; then
- kill "$OLD_PID" 2>/dev/null || true
- sleep 1
- if kill -0 "$OLD_PID" 2>/dev/null; then
- kill -9 "$OLD_PID" 2>/dev/null || true
- fi
- fi
+
+ # Kill ALL pulse processes (not just one) to prevent duplicates
+ pkill -f "^\./pulse$" 2>/dev/null || true
+ sleep 1
+ # Force kill any remaining
+ pkill -9 -f "^\./pulse$" 2>/dev/null || true
+ sleep 1
LOG_LEVEL=debug \
FRONTEND_PORT="${PULSE_DEV_API_PORT:-7655}" \
@@ -470,8 +493,13 @@ log_info "Starting backend file watcher..."
NEW_PID=$!
sleep 1
- if kill -0 "$NEW_PID" 2>/dev/null; then
+ # Verify exactly one process is running
+ PULSE_COUNT=$(pgrep -f "^\./pulse$" 2>/dev/null | wc -l | tr -d ' ')
+ if [[ "$PULSE_COUNT" -eq 1 ]] && kill -0 "$NEW_PID" 2>/dev/null; then
log_info "✓ Backend restarted (PID: $NEW_PID)"
+ elif [[ "$PULSE_COUNT" -gt 1 ]]; then
+ log_error "✗ Multiple processes after restart ($PULSE_COUNT) - killing all"
+ pkill -9 -f "^\./pulse$" 2>/dev/null || true
else
log_error "✗ Backend failed to start! Check /tmp/pulse-debug.log"
fi
diff --git a/scripts/sync-production-config.sh b/scripts/sync-production-config.sh
index 727c79fc4a..d6eba36600 100755
--- a/scripts/sync-production-config.sh
+++ b/scripts/sync-production-config.sh
@@ -11,6 +11,13 @@ DEV_DIR=${DEV_DIR:-"/opt/pulse/tmp/dev-config"}
mkdir -p "$DEV_DIR"
chmod 700 "$DEV_DIR"
+# If production config is missing, skip sync and let dev config stand alone.
+if [ ! -d "$PROD_DIR" ]; then
+ echo "⚠ Production config directory not found: $PROD_DIR"
+ echo "✓ Skipping production sync; using dev-only config in $DEV_DIR"
+ exit 0
+fi
+
# Copy essential production config files to dev
# Skip session/csrf/alert files which are runtime-specific
echo "Syncing production config to dev environment..."
diff --git a/scripts/toggle-mock.sh b/scripts/toggle-mock.sh
index 214e7cd78f..a21244edcc 100755
--- a/scripts/toggle-mock.sh
+++ b/scripts/toggle-mock.sh
@@ -9,8 +9,9 @@ YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
-MOCK_ENV_FILE="/opt/pulse/mock.env"
-ROOT_DIR="/opt/pulse"
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ROOT_DIR="$(dirname "$SCRIPT_DIR")"
+MOCK_ENV_FILE="${ROOT_DIR}/mock.env"
BACKEND_PORT=7656
DEV_DATA_DIR="${ROOT_DIR}/tmp/dev-config"
DEV_KEY_FILE="${DEV_DATA_DIR}/.encryption.key"