Simplify healthcheck implementation and update Docker healthcheck command.
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ services:
|
|||||||
whiteids: ${whiteids}
|
whiteids: ${whiteids}
|
||||||
rollback: ${rollback}
|
rollback: ${rollback}
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [ "CMD-SHELL", "python3 -c 'import requests; r=requests.get(\"http://127.0.0.1:8813/healthz\"); exit(0 if r.status_code==200 else 1)'" ]
|
test: ["CMD", "curl", "-f", "http://127.0.0.1:8813/healthz"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|||||||
+1
-14
@@ -51,17 +51,4 @@ def logs():
|
|||||||
@app.get("/healthz")
|
@app.get("/healthz")
|
||||||
async def healthcheck():
|
async def healthcheck():
|
||||||
"""Проверка здоровья для Docker."""
|
"""Проверка здоровья для Docker."""
|
||||||
# Cам FastAPI
|
return {"status": "ok"}
|
||||||
result = {"status": "ok"}
|
|
||||||
|
|
||||||
# Telegram API
|
|
||||||
try:
|
|
||||||
resp = requests.get(BOT_API_URL)
|
|
||||||
if resp.status_code != 200:
|
|
||||||
result["telegram_api"] = f"error {resp.status_code}"
|
|
||||||
else:
|
|
||||||
result["telegram_api"] = "ok"
|
|
||||||
except Exception as e:
|
|
||||||
result["telegram_api"] = str(e)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|||||||
Reference in New Issue
Block a user