From 8dfca5fb197eba39faba6291a3ca1b69d3293b8a Mon Sep 17 00:00:00 2001 From: black Date: Sat, 18 May 2024 16:42:59 -0500 Subject: [PATCH] fix: added healthcheck --- .github/workflows/deploy.yml | 2 ++ app.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2ed1025..e4a9fc6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,3 +15,5 @@ jobs: heroku_api_key: ${{ secrets.HEROKU_API_KEY }} heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} + healthcheck: "https://${secrets.HEROKU_APP}}/healthcheck" + rollbackonhealthcheckfailed: true diff --git a/app.py b/app.py index 4affaaa..7ce0654 100644 --- a/app.py +++ b/app.py @@ -31,6 +31,16 @@ async def lifespan(app: FastAPI): models.Base.metadata.create_all(bind=engine) +@app.get("/healthcheck") +def health(): + return "OK" + + +@app.get("/", status_code=200) +def health(): + return None + + @app.middleware("http") async def db_session_middleware(request: Request, call_next): response = Response("Internal server error", status_code=500)