-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
5d2121e
commit 2fc1b00
Showing
3 changed files
with
29 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
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() | ||
app = FastAPI(lifespan=lifespan) | ||
|
||
|
||
app.include_router(retrieve.router) | ||
app.include_router(ingest.router) | ||
|
||
|
||
@app.get('/') | ||
def read_root(): | ||
return {'Hello': 'World'} | ||
@app.get('/healthcheck') | ||
async def healthcheck(): | ||
return JSONResponse(content={'status': 'healthy'}, status_code=200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters