Pavlo Paliychuk 2fc1b00602
feat: add FastAPI lifespan and healthcheck endpoint (#144)
* chore: Add healthcheck endpoint + build indexes and constraints on svc startup

* chore: Bring back driver close call
2024-09-23 10:12:35 -04:00

30 lines
719 B
Python

from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from graph_service.config import get_settings
from graph_service.routers import ingest, retrieve
from graph_service.zep_graphiti import initialize_graphiti
@asynccontextmanager
async def lifespan(_: FastAPI):
settings = get_settings()
await initialize_graphiti(settings)
yield
# Shutdown
# No need to close Graphiti here, as it's handled per-request
app = FastAPI(lifespan=lifespan)
app.include_router(retrieve.router)
app.include_router(ingest.router)
@app.get('/healthcheck')
async def healthcheck():
return JSONResponse(content={'status': 'healthy'}, status_code=200)