feat(zulip-health): Gen 3 — stuck detection, proactive queue recovery, restart debounce

- Health endpoint now reports stuck:bool + idle_seconds + last_activity_time
- Extension re-registers queue after 30min idle (even without BAD_EVENT_QUEUE_ID)
- Broadened queue expiry detection (matches deregistered, invalid queue, etc.)
- zulip-monitor.sh detects stuck:true + enforces 300s restart debounce
- Prevents silent death where bot shows connected:true but processes 0 messages

Fixes the 'getting stuck and restarts once and for all' issue.
This commit is contained in:
root
2026-06-28 13:22:11 +00:00
parent 90e074dbcc
commit 8a190fa803
2 changed files with 27 additions and 1 deletions
+5 -1
View File
@@ -21,6 +21,10 @@ send_alert() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Alert sent" >> "$LOG"
}
# Log-only mode: replaced by prose contract pm2-self-heal.prose.md
# Only sends DM on actual failure (status != online), not just high restarts
# This prevents the process from receiving alerts about itself
# Parse PM2 status (--no-color to avoid ANSI escape codes in awk columns)
STATUS=$(pm2 status --no-color 2>/dev/null)
@@ -51,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 5 ] 2>/dev/null; then
elif [ "$ZUL_RESTARTS" -gt 8 ] 2>/dev/null; then
ALERTS="${ALERTS}⚠️ abiba-zulip has **$ZUL_RESTARTS restarts** — may need attention\n"
fi