fix(sensor-proxy): skip selfheal reinstall when service is healthy

The selfheal timer was running the full installer every 5 minutes even when
the service was already running and healthy. This caused unnecessary:
- Pulse service restarts
- Config migrations
- Socket setup
- 172MB memory spikes and 15s CPU usage per run

Now the selfheal exits early after checking service health, only proceeding
to reinstall logic if the service is actually failing.

Fixes #849
This commit is contained in:
rcourtman 2025-12-15 13:31:18 +00:00
parent b6cc57590a
commit 2209565eae

View file

@ -3523,6 +3523,13 @@ if ! command -v systemctl >/dev/null 2>&1; then
exit 0
fi
# Early exit if service is healthy - no work needed
if systemctl is-active --quiet "${SERVICE}.service" 2>/dev/null; then
# Service is running - only do control plane reconcile if needed, skip everything else
attempt_control_plane_reconcile
exit 0
fi
if ! systemctl list-unit-files 2>/dev/null | grep -q "^${SERVICE}\\.service"; then
if [[ -x "$INSTALLER" && -f "$CTID_FILE" ]]; then
log "Service unit missing; attempting reinstall"