From 5db2172363d99331ba25fe2f298af24d3d996d18 Mon Sep 17 00:00:00 2001 From: Kurbanov Bulat Date: Sat, 12 Feb 2022 13:17:59 +0300 Subject: [PATCH] Refactoring healthcheck --- scripts/healthcheck.py | 7 +------ src/app/views.py | 7 ++++++- src/core/app.py | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/healthcheck.py b/scripts/healthcheck.py index b7bd530..395ae27 100644 --- a/scripts/healthcheck.py +++ b/scripts/healthcheck.py @@ -1,11 +1,6 @@ -import os - import httpx -response = httpx.get( - "http://localhost:8080/api/v1/healthcheck", - headers={"Authorization": os.environ["API_KEY"]}, -) +response = httpx.get("http://localhost:8080/healthcheck") print(f"HEALTHCHECK STATUS: {response.status_code}") exit(0 if response.status_code == 200 else 1) diff --git a/src/app/views.py b/src/app/views.py index 924a75e..e91ad2c 100644 --- a/src/app/views.py +++ b/src/app/views.py @@ -117,6 +117,11 @@ async def update_cache(request: Request): return "Ok!" -@router.get("/healthcheck") +healthcheck_router = APIRouter( + tags=["healthcheck"], +) + + +@healthcheck_router.get("/healthcheck") async def healthcheck(): return "Ok!" diff --git a/src/core/app.py b/src/core/app.py index 274490b..12e2f44 100644 --- a/src/core/app.py +++ b/src/core/app.py @@ -2,7 +2,7 @@ from fastapi import FastAPI from prometheus_fastapi_instrumentator import Instrumentator -from app.views import router +from app.views import router, healthcheck_router from core.arq_pool import get_arq_pool from core.db import database @@ -13,6 +13,7 @@ def start_app() -> FastAPI: app.state.database = database app.include_router(router) + app.include_router(healthcheck_router) @app.on_event("startup") async def startup() -> None: