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.

fix(agent): kill old QNAP agent processes during upgrade (#1317)

rcourtmancdceccef05e7
diff --git a/scripts/install.sh b/scripts/install.sh
index 10123530b2..f8683ac60a 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -58,6 +58,19 @@ LOG_FILE="/var/log/${AGENT_NAME}.log"
QNAP=false
QNAP_VOL=""
+# Stop all QNAP pulse-agent processes (wrappers first, then binaries).
+# Kill wrappers first to prevent watchdog respawn, then binaries.
+stop_qnap_agents() {
+ # 1. Kill wrapper scripts (watchdog loops)
+ pkill -f "start-pulse-agent\.sh" 2>/dev/null || true
+ sleep 1
+ # 2. Kill agent binaries at both possible paths (with or without leading /)
+ pkill -f "(^|/)pulse-agent( |$)" 2>/dev/null || true
+ sleep 2
+ # 3. Verify — force-kill any survivors
+ pkill -9 -f "(^|/)pulse-agent( |$)" 2>/dev/null || true
+}
+
# TrueNAS SCALE configuration (immutable root filesystem)
TRUENAS=false
TRUENAS_STATE_DIR="/data/pulse-agent"
@@ -904,8 +917,12 @@ if [[ -x "$UPGRADE_CHECK_BIN" ]]; then
fi
# Also kill any running process in case it was started manually
- pkill -f "^${INSTALL_DIR}/${BINARY_NAME}" 2>/dev/null || true
- sleep 1
+ if [[ "$QNAP" == true ]]; then
+ stop_qnap_agents
+ else
+ pkill -f "^${INSTALL_DIR}/${BINARY_NAME}" 2>/dev/null || true
+ sleep 1
+ fi
fi
elif command -v systemctl >/dev/null 2>&1 && systemctl is-enabled --quiet "${AGENT_NAME}" 2>/dev/null; then
# Service exists but binary is missing - reinstall scenario
@@ -1267,11 +1284,9 @@ if [[ "$QNAP" == true ]]; then
build_exec_args
build_exec_args_array
- # Kill any existing pulse agents (use -x for exact process name match to
- # avoid killing the wrapper script whose path also contains "pulse-agent")
+ # Kill any existing pulse agents (wrappers + binaries at old and new paths)
log_info "Stopping any existing pulse agents..."
- pkill -x "${BINARY_NAME}" 2>/dev/null || true
- sleep 2
+ stop_qnap_agents
# Create a wrapper script (stored persistently)
# At boot the RAM disk is empty, so the wrapper copies the binary there for
@@ -1283,9 +1298,8 @@ if [[ "$QNAP" == true ]]; then
# Pulse Agent startup script for QNAP
# Auto-generated by Pulse installer
-# Kill any existing pulse-agent processes (-x = exact process name match,
-# avoids killing this wrapper whose path also contains "pulse-agent")
-pkill -x "${BINARY_NAME}" 2>/dev/null || true
+# Kill any running pulse-agent binary processes
+pkill -f "(^|/)pulse-agent( |\$)" 2>/dev/null || true
sleep 2
# Copy binary from persistent storage to /usr/local/bin (RAM disk, wiped on reboot).