From 5954ea9401a73905666f4f8a9aea25d7208a8f81 Mon Sep 17 00:00:00 2001 From: sky Date: Sun, 14 Sep 2025 05:59:39 +0200 Subject: [PATCH] =?UTF-8?q?date=20heure=20pour=20le=20fichiers=20log=20et?= =?UTF-8?q?=20max=20retry=20corrig=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- start.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b34484..bc3ab9c 100755 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,6 @@ RUN python3 -m venv /app/venv && \ mkdir -p /app/logs HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ - CMD pgrep python > /dev/null && ! (tail -n 1000 /app/logs/*.log 2>/dev/null | grep -iE "(ERROR|CRITICAL|Exception|sqlite3\.OperationalError)") || exit 1 + CMD pgrep python > /dev/null && ! (tail -n 1000 $(ls -t /app/logs/*.log 2>/dev/null | head -1) 2>/dev/null | grep -iE "(ERROR|CRITICAL|Exception|sqlite3\.OperationalError)") || (echo "Healthcheck échoué, arrêt du conteneur" && kill 1) CMD ["/start.sh"] diff --git a/start.sh b/start.sh index d66e5c0..3f83efa 100644 --- a/start.sh +++ b/start.sh @@ -1,6 +1,7 @@ #!/bin/bash echo "Démarrage du bot Discord..." +LOG_FILE="/app/logs/$(date '+%Y%m%d_%H%M%S').log" exec /app/venv/bin/python run-web.py 2>&1 | while IFS= read -r line; do - echo "$(date '+%Y-%m-%d %H:%M:%S%z') $line" | tee -a /app/logs/$(hostname).log # RFC 3339 / ISO 8601 + echo "$(date '+%Y-%m-%d %H:%M:%S%z') $line" | tee -a "$LOG_FILE" # RFC 3339 / ISO 8601 done \ No newline at end of file