Erinnerungen & Routinen (A3): Wecker in MC2 + Hermes-Tools
- services/reminders.py: persistenter Store (/srv/models/mc2-reminders.json), Wecker-Loop feuert in Briefkasten (Lucy spricht) + Telegram; repeat daily/weekdays/weekly; naive Zeiten = Commander-TZ (Europe/Berlin, Box ist UTC); verpasste Einmal-Erinnerungen feuern verspätet nach (ehrlich markiert) - routers/reminders.py: GET/POST/DELETE /api/reminders - mcp_mc.py: reminder_create/list/delete (Guards, ISO aus Sofort-Kontext) - announce.notify_telegram als gemeinsamer Helper (sentry nutzt ihn jetzt) - requirements: tzdata (zoneinfo-Fallback, Windows-Dev) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,8 +16,6 @@ Braucht KEIN sudo, keine neuen Dienste — läuft als asyncio-Task im MC2-Backen
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
import httpx
|
||||
@@ -34,8 +32,6 @@ START_DELAY = int(os.environ.get("MC_SENTRY_START_DELAY", "90")) # Dienste nac
|
||||
FAIL_AFTER = int(os.environ.get("MC_SENTRY_FAIL_AFTER", "3")) # Fehl-Ticks bis Alarm (3×120s = 6 min)
|
||||
REMIND_S = int(os.environ.get("MC_SENTRY_REMIND_S", "21600")) # Erinnerung bei Dauerproblem: 6 h
|
||||
DISK_ALARM_PCT = float(os.environ.get("MC_SENTRY_DISK_PCT", "90"))
|
||||
NOTIFY_SH = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
|
||||
"deploy", "notify.sh")
|
||||
|
||||
|
||||
def _reach(url: str, path: str = "/health") -> bool:
|
||||
@@ -102,16 +98,9 @@ _watches: dict[str, _Watch] = {name: _Watch() for name in CHECKS}
|
||||
|
||||
|
||||
def _notify_telegram(subject: str, text: str) -> None:
|
||||
"""Best-effort auch auf Telegram (User ist evtl. nicht am PC). notify.sh spiegelt
|
||||
seinerseits in den Briefkasten — als Quelle 'sentry' markierte Einträge legt der
|
||||
Wächter aber schon selbst ab, darum hier der Direktweg NUR für Telegram."""
|
||||
if not (os.name == "posix" and shutil.which("bash")):
|
||||
return # Dev auf Windows: kein hermes/notify
|
||||
try:
|
||||
subprocess.run(["bash", NOTIFY_SH, "-s", subject, text + " (Diese Meldung kam auch an Lucy.)"],
|
||||
timeout=30, capture_output=True, env={**os.environ, "MC_NOTIFY_NO_ANNOUNCE": "1"})
|
||||
except Exception:
|
||||
log.warning("sentry: notify.sh fehlgeschlagen", exc_info=True)
|
||||
"""Telegram-Direktweg (gemeinsamer Helper in announce.py); Briefkasten-Eintrag
|
||||
legt der Wächter selbst ab."""
|
||||
announce.notify_telegram(subject, text + " (Diese Meldung kam auch an Lucy.)")
|
||||
|
||||
|
||||
def _tick() -> None:
|
||||
|
||||
Reference in New Issue
Block a user