This commit is contained in:
2026-11-27 16:42:18 +03:00
parent 20afc2c790
commit a884c07867
133 changed files with 27001 additions and 120 deletions
+22
View File
@@ -0,0 +1,22 @@
"""Проверка живости worker/relay по heartbeat-файлу для Docker HEALTHCHECK."""
from __future__ import annotations
import os
import time
from pathlib import Path
DEFAULT_TIMEOUT_SECONDS = 30.0
def main() -> int:
path = Path(os.environ.get("HEARTBEAT_FILE", "/tmp/messenger-worker-heartbeat"))
timeout = float(os.environ.get("HEARTBEAT_TIMEOUT_SECONDS", DEFAULT_TIMEOUT_SECONDS))
try:
age = time.time() - path.stat().st_mtime
except OSError:
return 1
return 0 if age <= timeout else 1
if __name__ == "__main__":
raise SystemExit(main())