mirror of
https://github.com/flibusta-apps/books_downloader.git
synced 2025-12-06 15:05:37 +01:00
Refactor healthcheck
This commit is contained in:
@@ -1,11 +1,8 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
response = httpx.get(
|
response = httpx.get(
|
||||||
"http://localhost:8080/healthcheck",
|
"http://localhost:8080/healthcheck"
|
||||||
headers={"Authorization": os.environ["API_KEY"]},
|
|
||||||
)
|
)
|
||||||
print(f"HEALTHCHECK STATUS: {response.status_code}")
|
print(f"HEALTHCHECK STATUS: {response.status_code}")
|
||||||
exit(0 if response.status_code == 200 else 1)
|
exit(0 if response.status_code == 200 else 1)
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ async def get_filename(book_id: int, file_type: str):
|
|||||||
return _get_filename(book.remote_id, book, file_type)
|
return _get_filename(book.remote_id, book, file_type)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/healthcheck")
|
healthcheck_router = APIRouter(
|
||||||
|
tags=["healthcheck"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@healthcheck_router.get("/healthcheck")
|
||||||
async def healthcheck():
|
async def healthcheck():
|
||||||
return "Ok!"
|
return "Ok!"
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ from fastapi import FastAPI
|
|||||||
|
|
||||||
from prometheus_fastapi_instrumentator import Instrumentator
|
from prometheus_fastapi_instrumentator import Instrumentator
|
||||||
|
|
||||||
from app.views import router
|
from app.views import router, healthcheck_router
|
||||||
|
|
||||||
|
|
||||||
def start_app() -> FastAPI:
|
def start_app() -> FastAPI:
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
app.include_router(router)
|
app.include_router(router)
|
||||||
|
app.include_router(healthcheck_router)
|
||||||
|
|
||||||
Instrumentator().instrument(app).expose(app, include_in_schema=True)
|
Instrumentator().instrument(app).expose(app, include_in_schema=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user