Premier commit
Build and Push Docker Image / build-and-push (push) Failing after 38s

This commit is contained in:
pyriec
2026-09-09 18:51:08 +02:00
commit 3d06c9a7ee
8 changed files with 733 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
import os
import sys
import json
import time
HEALTH_FILE = "/tmp/health_status.json"
if not os.path.exists(HEALTH_FILE):
print("Healthcheck ÉCHEC : Fichier d'état introuvable.")
sys.exit(1)
try:
with open(HEALTH_FILE, "r", encoding="utf-8") as f:
data = json.load(f)
interval = int(os.getenv("CHECK_INTERVAL", "3600"))
# Marge de sécurité (ex: 2x l'intervalle + 10 min) avant de déclarer le conteneur unhealthy
max_allowed_age = interval * 2 + 600
last_heartbeat = data.get("timestamp", 0)
status = data.get("status", "unknown")
age = time.time() - last_heartbeat
if age > max_allowed_age:
print(f"Healthcheck ÉCHEC : Fichier trop ancien ({int(age)}s > {max_allowed_age}s)")
sys.exit(1)
if status in ("ok", "running"):
sys.exit(0)
else:
print(f"Healthcheck ÉCHEC : Statut du script est '{status}'")
sys.exit(1)
except Exception as e:
print(f"Healthcheck ÉCHEC : Erreur de lecture : {e}")
sys.exit(1)