Skip to content

Commit

Permalink
Add API health check (#8)
Browse files Browse the repository at this point in the history
* Add API health check

Signed-off-by: Alex Co <alex.tuan@mindvalley.com>

* Change library

Signed-off-by: Alex Co <alex.tuan@mindvalley.com>

* reformatted

Signed-off-by: Alex Co <alex.tuan@mindvalley.com>

---------

Signed-off-by: Alex Co <alex.tuan@mindvalley.com>
  • Loading branch information
onimsha authored Apr 19, 2024
1 parent cd43e94 commit 5b1ce75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions backend/danswer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import uvicorn
from fastapi import APIRouter
from fastapi import FastAPI

from fastapi import Request
from fastapi.exceptions import RequestValidationError
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from fastapi_health import health
from httpx_oauth.clients.google import GoogleOAuth2
from sqlalchemy.orm import Session

Expand Down Expand Up @@ -343,6 +345,11 @@ def get_application() -> FastAPI:
RequestValidationError, validation_exception_handler
)

def healthz_check():
return True

application.add_api_route("/healthz", health([healthz_check]))

application.add_exception_handler(ValueError, value_error_handler)

application.add_middleware(
Expand Down
1 change: 1 addition & 0 deletions backend/requirements/default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dask==2023.8.1
ddtrace==2.6.5
distributed==2023.8.1
fastapi==0.109.2
fastapi-health==0.4.0
fastapi-users==12.1.3
fastapi-users-db-sqlalchemy==5.0.0
filelock==3.12.0
Expand Down

0 comments on commit 5b1ce75

Please sign in to comment.