opensearch health check
This commit is contained in:
parent
88c09846c0
commit
bc639d190b
1 changed files with 24 additions and 0 deletions
24
src/main.py
24
src/main.py
|
|
@ -21,6 +21,7 @@ from functools import partial
|
||||||
|
|
||||||
from starlette.applications import Starlette
|
from starlette.applications import Starlette
|
||||||
from starlette.routing import Route
|
from starlette.routing import Route
|
||||||
|
from starlette.responses import JSONResponse
|
||||||
|
|
||||||
# Set multiprocessing start method to 'spawn' for CUDA compatibility
|
# Set multiprocessing start method to 'spawn' for CUDA compatibility
|
||||||
multiprocessing.set_start_method("spawn", force=True)
|
multiprocessing.set_start_method("spawn", force=True)
|
||||||
|
|
@ -456,6 +457,24 @@ async def _ingest_default_documents_langflow(services, file_paths):
|
||||||
file_count=len(file_paths),
|
file_count=len(file_paths),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def opensearch_health_ready(request):
|
||||||
|
"""Readiness probe: verifies OpenSearch dependency is reachable."""
|
||||||
|
try:
|
||||||
|
# Fast check that the cluster is reachable/auth works
|
||||||
|
await asyncio.wait_for(clients.opensearch.info(), timeout=5.0)
|
||||||
|
return JSONResponse(
|
||||||
|
{"status": "ready", "dependencies": {"opensearch": "up"}},
|
||||||
|
status_code=200,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
return JSONResponse(
|
||||||
|
{
|
||||||
|
"status": "not_ready",
|
||||||
|
"dependencies": {"opensearch": "down"},
|
||||||
|
"error": str(e),
|
||||||
|
},
|
||||||
|
status_code=503,
|
||||||
|
)
|
||||||
|
|
||||||
async def _ingest_default_documents_openrag(services, file_paths):
|
async def _ingest_default_documents_openrag(services, file_paths):
|
||||||
"""Ingest default documents using traditional OpenRAG processor."""
|
"""Ingest default documents using traditional OpenRAG processor."""
|
||||||
|
|
@ -1148,6 +1167,11 @@ async def create_app():
|
||||||
),
|
),
|
||||||
methods=["GET"],
|
methods=["GET"],
|
||||||
),
|
),
|
||||||
|
Route(
|
||||||
|
"/search/health",
|
||||||
|
opensearch_health_ready,
|
||||||
|
methods=["GET"],
|
||||||
|
),
|
||||||
# Models endpoints
|
# Models endpoints
|
||||||
Route(
|
Route(
|
||||||
"/models/openai",
|
"/models/openai",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue