Skip to content

feat: BotProcessDied event — process watcher + auto-restart (#621)#633

Merged
ShaerWare merged 1 commit intomainfrom
server/eventbus-bot-process-watcher
Mar 20, 2026
Merged

feat: BotProcessDied event — process watcher + auto-restart (#621)#633
ShaerWare merged 1 commit intomainfrom
server/eventbus-bot-process-watcher

Conversation

@ShaerWare
Copy link
Owner

Summary

  • Add BotProcessDied event in modules/channels/events.py — shared across Telegram/WhatsApp
  • Add periodic bot-process-watcher task (30s interval via TaskRegistry) that detects dead bot subprocesses and publishes events
  • Two EventBus subscribers: audit logging (via AuditService) and auto-restart with backoff (max 3 retries, 10/20/30s delays)
  • Graceful exits (code=0) are logged but not restarted; restart counter resets after stable run (>60s uptime)
  • 10 unit tests covering: dead process detection (telegram + whatsapp), running process ignored, audit logging, graceful exit skip, backoff delay, max restart limit, counter reset, subscription wiring, event fields

Test plan

  • All 10 new tests pass (pytest tests/unit/test_bot_process_watcher.py)
  • All 97 unit tests pass (no regressions)
  • CI checks (lint-backend, lint-frontend, security)

Closes #621

🤖 Generated with Claude Code

…621)

Add periodic bot process watcher that detects dead Telegram/WhatsApp
subprocess deaths and reacts via EventBus: audit logging + auto-restart
with backoff (max 3 retries, 10/20/30s delays).

New files:
- modules/channels/events.py — BotProcessDied event
- modules/channels/startup.py — watcher task, audit handler, auto-restart
- tests/unit/test_bot_process_watcher.py — 10 unit tests

Changed:
- orchestrator.py — register bot-process-watcher periodic task (30s)
- modules/core/startup.py — wire channel event subscriptions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ShaerWare ShaerWare merged commit 4b925f1 into main Mar 20, 2026
3 checks passed
@ShaerWare ShaerWare deleted the server/eventbus-bot-process-watcher branch March 20, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 5.5: BotProcessDied event — process watcher + auto-restart + monitoring

2 participants