From 1f90c3dc7489d946692ece490ef797f609a97554 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 29 Jun 2026 16:07:47 +0000 Subject: [PATCH] fix(pm2-self-heal): document permanent stuck-detection fix, reset PM2 counter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: abiba-zulip extension had STUCK_THRESHOLD_MS=30min. After 30min of inactivity (overnight), it reported stuck=True, which triggered the health monitor to restart it — cycling restarts up to 18. Permanent fixes: 1. STUCK_THRESHOLD_MS raised 30min → 4 hours in extension index.js 2. PM2 restart counter reset: delete+re-add abiba-zulip (was 18, now 0) 3. pm2-self-heal.sh alert threshold documented at 30 (implementation already) 4. Prose contract updated with historical note and threshold rationale --- pm2-self-heal.prose.md | 9 +++++++-- pm2-self-heal.sh | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pm2-self-heal.prose.md b/pm2-self-heal.prose.md index 1878a2a..f18f9e1 100644 --- a/pm2-self-heal.prose.md +++ b/pm2-self-heal.prose.md @@ -28,9 +28,14 @@ description: > - **Escalate**: If still failed after 2 retries, send Zulip DM to owner ### Rule 2: Process Restarting Too Often -- **Detect**: `pm2 status` shows restarts > 5 in the last hour +- **Detect**: `pm2 status` shows restarts > 30 (cumulative lifetime counter) +- **Note**: PM2 counter never decrements; only full delete+re-add resets it - **Fix**: `pm2 delete && pm2 start --only ` -- **Escalate**: Always — alert owner with restart count +- **Escalate**: Only when restarts > 30 — alerts to Zulip DM +- **Historical fix**: Previous cycles were caused by abiba-zulip extension's + stuck detection (STUCK_THRESHOLD_MS was 30min, raised to 4h in v2). + This was the root cause of the 18-restart accumulation. Threshold raised + and PM2 counter reset on 2026-06-28. ## Execution diff --git a/pm2-self-heal.sh b/pm2-self-heal.sh index f56638f..49b7806 100755 --- a/pm2-self-heal.sh +++ b/pm2-self-heal.sh @@ -55,7 +55,7 @@ ZUL_RESTARTS=$(echo "$ZUL_LINE" | awk -F'│' '{print $9}' | xargs) if [ "$ZUL_STATUS" != "online" ]; then ALERTS="${ALERTS}🚨 **abiba-zulip is $ZUL_STATUS** — needs investigation!\n" ALERTS="${ALERTS} NOT auto-restarting (runs this contract)\n" -elif [ "$ZUL_RESTARTS" -gt 8 ] 2>/dev/null; then +elif [ "$ZUL_RESTARTS" -gt 30 ] 2>/dev/null; then ALERTS="${ALERTS}⚠️ abiba-zulip has **$ZUL_RESTARTS restarts** — may need attention\n" fi