- DELETE infrastructure-monitoring.prose.md (redundant — proxmox-monitor already deployed this) - FIX infrastructure-control.prose.md: remove /grafana/ nginx route (reverted Jul 2, broke gpu-fleet) - FIX infrastructure-update.prose.md: wrong CT IDs (122→112 Tanko, 123→114 Mumuni, .19→storepve Zulip) - FIX infrastructure-update.prose.md: Strix Halo :8080→router health check (firewalled to .116 only) - FIX proxmox-monitor.prose.md: stale /grafana/ URLs→:3001 (post-revert cleanup) - ADD disk-gc-threat-response.prose.md: verified run (2026-07-04, reclaimed 35.67GB from kagentz) - ADD infrastructure-update.prose.md, pi-approval-architecture.prose.md, zulip-approval-fix.prose.md, zulip-self-heal.prose.md - UPDATE hermes-config, litellm-health/self-heal, pm2-self-heal, zulip-* contracts - ADD runs/20260704-005804-51f9a9 (disk-gc-threat-response run artifacts) All contracts verified against live PVE API, nginx config, and firewall state.
87 lines
3.1 KiB
Markdown
87 lines
3.1 KiB
Markdown
---
|
|
kind: responsibility
|
|
name: pm2-self-heal
|
|
description: >
|
|
Monitors critical PM2 processes (abiba-zulip, abiba-telegram) and
|
|
auto-restarts any that are stopped or errored. Logs every action to
|
|
the knowledge graph and alerts the owner via Zulip DM on failures.
|
|
CRITICAL: Never restart abiba-zulip — it runs this contract.
|
|
---
|
|
|
|
## Maintains
|
|
|
|
- abiba-telegram: { status: "online", uptime: string, restarts: number }
|
|
- gpu-watchdog: { status: "online", uptime: string, restarts: number }
|
|
- gitea-runner: { status: "online", uptime: string, restarts: number }
|
|
- last_check: timestamp
|
|
|
|
> **Note (2026-07-04):** `abiba-zulip` removed — Zulip extension decommissioned.
|
|
|
|
## Continuity
|
|
|
|
- Self-driven: check every 300 seconds (5 min)
|
|
- Also wakes on user request (`prose run pm2-self-heal`)
|
|
|
|
## Remediation Rules
|
|
|
|
### Rule 1: Process Stopped or Errored
|
|
- **Detect**: `pm2 status` shows "stopped" or "errored" for a named process
|
|
- **Fix**: `pm2 restart <name>`
|
|
- **Verify**: Re-check status after 5 seconds
|
|
- **Escalate**: If still failed after 2 retries, send Zulip DM to owner
|
|
|
|
### Rule 2: Process Restarting Too Often
|
|
- **Detect**: `pm2 status` shows restarts > 30 (cumulative lifetime counter)
|
|
- **Note**: PM2 counter never decrements; only full delete+re-add resets it
|
|
- **Fix**: `pm2 delete <name> && pm2 start <ecosystem> --only <name>`
|
|
- **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
|
|
|
|
1. **Check PM2 status** — Run `pm2 status --no-color` and parse the table (5th data column = PID, 8th = restarts, 9th = status)
|
|
2. **Check abiba-telegram**:
|
|
- If status is "online" → pass
|
|
- If status is "stopped" or "errored" → apply Rule 1
|
|
- If restarts > 5 → alert owner
|
|
3. **Check abiba-zulip** (self-process, read-only):
|
|
- If status is "online" → pass, log restarts count
|
|
- If status is "stopped" or "errored" → **DO NOT RESTART** — alert owner immediately
|
|
- If restarts > 5 in last hour → alert owner with full diagnostics
|
|
4. **Log results** — Create `[LEARN]` node in knowledge graph for any actions taken
|
|
5. **Alert** — Send Zulip DM to owner if escalation needed (do NOT run pm2 commands during alerting)
|
|
6. **Wait 5 min** → repeat from step 1
|
|
|
|
## Example Output (when healthy)
|
|
|
|
```json
|
|
{
|
|
"run_id": "pm2-heal-001",
|
|
"checked_at": "2026-06-26T15:00:00Z",
|
|
"processes": {
|
|
"abiba-zulip": { "status": "online", "uptime": "2h", "restarts": 0 },
|
|
"abiba-telegram": { "status": "online", "uptime": "48h", "restarts": 0 }
|
|
},
|
|
"actions_taken": [],
|
|
"overall": "healthy"
|
|
}
|
|
```
|
|
|
|
## Example Output (when fixed)
|
|
|
|
```json
|
|
{
|
|
"processes": {
|
|
"abiba-telegram": { "status": "errored → restarted → online" },
|
|
"abiba-zulip": { "status": "online", "uptime": "2h", "restarts": 0 }
|
|
},
|
|
"actions_taken": [
|
|
{ "target": "abiba-telegram", "action": "pm2 restart", "result": "online" }
|
|
],
|
|
"overall": "fixed"
|
|
}
|
|
```
|