Skip to content

Commit f9afdd7

Browse files
committed
Add check in python side
1 parent 7068eaf commit f9afdd7

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

  • ai-vision-service/face-recognition/app

ai-vision-service/face-recognition/app/main.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from contextlib import asynccontextmanager
1515
from typing import TYPE_CHECKING, Any
1616

17+
import httpx
1718
from fastapi import FastAPI
1819

1920
from app.api.routes import router
@@ -42,6 +43,27 @@ async def _default_lifespan(app: FastAPI) -> AsyncGenerator[None]:
4243
# Configure logging
4344
logging.basicConfig(level=getattr(logging, settings.log_level.upper(), logging.INFO))
4445

46+
# Verify Lychee connectivity
47+
lychee_up_url = f"{settings.lychee_api_url}/up"
48+
logger.info("Checking Lychee connectivity at %s", lychee_up_url)
49+
try:
50+
async with httpx.AsyncClient(verify=settings.verify_ssl, timeout=10.0) as client:
51+
response = await client.get(lychee_up_url)
52+
response.raise_for_status()
53+
logger.info("✓ Lychee is reachable (status=%d)", response.status_code)
54+
except httpx.HTTPStatusError as e:
55+
logger.error("✗ Lychee /up endpoint returned status %d", e.response.status_code)
56+
raise RuntimeError(
57+
f"Lychee health check failed: /up returned {e.response.status_code}. "
58+
"Ensure VISION_FACE_LYCHEE_API_URL is correct and Lychee is running."
59+
) from e
60+
except httpx.RequestError as e:
61+
logger.error("✗ Cannot connect to Lychee at %s: %s", lychee_up_url, e)
62+
raise RuntimeError(
63+
f"Cannot connect to Lychee at {lychee_up_url}. "
64+
"Ensure VISION_FACE_LYCHEE_API_URL is correct and Lychee is reachable."
65+
) from e
66+
4567
# Load detector
4668
from app.detection.detector import FaceDetector
4769

0 commit comments

Comments
 (0)