mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-16 04:50:39 +01:00
ajout healthcheck.py
This commit is contained in:
@@ -30,11 +30,12 @@ COPY ./webapp ./webapp
|
|||||||
COPY ./twitchbot ./twitchbot
|
COPY ./twitchbot ./twitchbot
|
||||||
COPY zabbix_agent2.conf /etc/zabbix/zabbix_agent2.conf
|
COPY zabbix_agent2.conf /etc/zabbix/zabbix_agent2.conf
|
||||||
COPY start.sh /start.sh
|
COPY start.sh /start.sh
|
||||||
|
COPY healthcheck.py .
|
||||||
|
|
||||||
RUN python3 -m venv /app/venv && \
|
RUN python3 -m venv /app/venv && \
|
||||||
/app/venv/bin/pip install --no-cache-dir -r requirements.txt && \
|
/app/venv/bin/pip install --no-cache-dir -r requirements.txt && \
|
||||||
chmod +x /start.sh
|
chmod +x /start.sh
|
||||||
|
|
||||||
HEALTHCHECK --interval=5m --timeout=1m --start-period=2m CMD /app/venv/bin/python /app/healthcheck.py --show-success --config-dir /app/config/ --hook-dir /app/config/healthcheck/
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=2m CMD /app/venv/bin/python /app/healthcheck.py
|
||||||
|
|
||||||
CMD ["/start.sh"]
|
CMD ["/start.sh"]
|
||||||
|
|||||||
27
healthcheck.py
Executable file
27
healthcheck.py
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
def check_process():
|
||||||
|
"""Vérifie si le processus Python principal est en cours d'exécution"""
|
||||||
|
try:
|
||||||
|
# Vérifier si le processus run-web.py est actif
|
||||||
|
result = subprocess.run(
|
||||||
|
["pgrep", "-f", "run-web.py"],
|
||||||
|
capture_output=True,
|
||||||
|
text=True
|
||||||
|
)
|
||||||
|
return result.returncode == 0
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if check_process():
|
||||||
|
sys.exit(0) # Succès
|
||||||
|
else:
|
||||||
|
sys.exit(1) # Échec
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user