推送频率各个类型的警告各自限制频率

This commit is contained in:
zqc
2026-03-11 10:53:54 +08:00
parent e7ec268b24
commit 2fd67fc656
3 changed files with 31 additions and 7 deletions

View File

@@ -11,6 +11,12 @@ HLS_ROOT_PATH = ""
HLS_SEGMENT_PATTERN = "segment_%09d.ts" # TS文件命名模式
# 默认告警推送间隔(秒)
ALERT_PUSH_INTERVAL = 5.0
# 各 action 的推送间隔配置 {action_code: interval_seconds}
ALERT_PUSH_INTERVALS = {}
# 视频剪辑配置
VIDEO_CLIP_OUTPUT_DIR = ""
VIDEO_CLIP_DURATION_SECONDS = 30
@@ -27,6 +33,7 @@ def init_config(config_path: str = "config.yaml"):
"""
global ALERT_PUSH_URL, HLS_ROOT_PATH
global VIDEO_CLIP_OUTPUT_DIR, VIDEO_CLIP_DURATION_SECONDS, VIDEO_CLIP_RETENTION_SECONDS, VIDEO_CLIP_DEFAULT_SEGMENT_DURATION
global ALERT_PUSH_INTERVALS
try:
with open(config_path, "r", encoding="utf-8") as f:
@@ -41,6 +48,9 @@ def init_config(config_path: str = "config.yaml"):
VIDEO_CLIP_RETENTION_SECONDS = cfg.get("video_clip_retention_seconds", 3600)
VIDEO_CLIP_DEFAULT_SEGMENT_DURATION = cfg.get("video_clip_default_segment_duration", 2)
# 告警推送间隔配置
ALERT_PUSH_INTERVALS = cfg.get("alert_push_intervals", {})
logger.info(f"[INFO] Config initialized from {config_path}, alert_push_url={ALERT_PUSH_URL}")
except Exception as e: