feat: hot reload for config/templates and GitPython-based hot update with pre-update notification

This commit is contained in:
snowy-yang committed 2026-09-12 19:59:39 +08:00
1 parent 8775c022bd
commit 67776b0092
7 files changed
+164 -5

No files matched your search

+13
View File
@@ -26,6 +26,19 @@ class Alerter:
self._last_alert_ts = 0.0
self._task = None
def apply_config(self, cfg: dict):
"""热重载告警参数(保留告警状态)。"""
self.interval = cfg.get("interval", self.interval)
new_threshold = cfg.get("cpu_threshold", self.threshold)
if new_threshold != self.threshold:
log.info("告警阈值变更: %.0f%% -> %.0f%%", self.threshold, new_threshold)
self.threshold = new_threshold
self.consecutive_need = cfg.get("consecutive", self.consecutive_need)
self.cooldown = cfg.get("cooldown", self.cooldown)
self.top_n = cfg.get("top_n", self.top_n)
self.groups = cfg.get("groups", self.groups) or []
self.friends = cfg.get("friends", self.friends) or []
def start(self):
self._task = asyncio.get_running_loop().create_task(self._loop())