forked from mtusi2026/mtusi2026lab3
Исходная точка lab3: код из solution/bvt2302-bodanyuk лабы 2, коммит ef44e48 (PR mtusi2026/mtusi2026lab2#42 принят). README, COURSE, contracts/ и tests/ преподавателя не тронуты; к Makefile дописан студенческий раздел lab2, .env.example — версия lab2. Исследование трека 2 lab2 (bench/track2) не переносилось. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
515 B
Python
20 lines
515 B
Python
"""Docker HEALTHCHECK probe without curl/wget in the image: `python -m messenger.healthcheck`."""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
import urllib.request
|
|
|
|
|
|
def main() -> int:
|
|
port = os.environ.get("APP_PORT", "8080").strip() or "8080"
|
|
try:
|
|
with urllib.request.urlopen(f"http://127.0.0.1:{port}/health/ready", timeout=2) as response:
|
|
return 0 if response.status == 200 else 1
|
|
except Exception:
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|