Merge pull request #792 from langflow-ai/open-search-health
opensearch health check
This commit is contained in:
commit
594a237842
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.routing import Route
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
# Set multiprocessing start method to 'spawn' for CUDA compatibility
|
||||
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),
|
||||
)
|
||||
|
||||
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):
|
||||
"""Ingest default documents using traditional OpenRAG processor."""
|
||||
|
|
@ -1148,6 +1167,11 @@ async def create_app():
|
|||
),
|
||||
methods=["GET"],
|
||||
),
|
||||
Route(
|
||||
"/search/health",
|
||||
opensearch_health_ready,
|
||||
methods=["GET"],
|
||||
),
|
||||
# Models endpoints
|
||||
Route(
|
||||
"/models/openai",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue