feat(telegram): 新增心跳監控防止沉默盲點
功能: - send_heartbeat(): 每 30 分鐘發送系統狀態 - start_heartbeat_monitor(): 背景心跳監控 - 沉默告警: 超過 2 小時沒訊息自動告警 目的: - 避免 Telegram 長時間沒訊息被當成「系統穩定」 - 主動驗證告警鏈路是否正常運作 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -115,6 +115,16 @@ async def lifespan(_app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
else:
|
||||
logger.info("telegram_polling_disabled", reason="OpenClaw 是唯一 Polling 實例")
|
||||
|
||||
# Phase 6.5: Telegram 心跳監控 (防止沉默盲點)
|
||||
# - 每 30 分鐘發送心跳,證明告警鏈路正常
|
||||
# - 超過 2 小時沒訊息則告警
|
||||
if settings.OPENCLAW_TG_BOT_TOKEN:
|
||||
await telegram_gw.start_heartbeat_monitor(
|
||||
heartbeat_interval_minutes=30,
|
||||
silence_threshold_hours=2,
|
||||
)
|
||||
logger.info("telegram_heartbeat_monitor_started")
|
||||
|
||||
# Phase 6.1: 啟動 Signal Worker (Redis Streams Consumer)
|
||||
# 統帥鐵律: Event Bus 解耦告警接收與處理
|
||||
await init_signal_worker()
|
||||
|
||||
Reference in New Issue
Block a user