Files
mtusi2026lab2/src/healthcheck.py
T

16 lines
452 B
Python

"""healthcheck докера"""
import json
import os
from urllib.request import urlopen
if __name__ == "__main__":
port = os.environ.get("APP_PORT", "8080")
try:
with urlopen(f"http://127.0.0.1:{port}/health/ready", timeout=2) as response:
ready = response.status == 200 and json.load(response) == {"status": "ok"}
raise SystemExit(0 if ready else 1)
except (OSError, ValueError):
raise SystemExit(1)