mirror of
https://github.com/flibusta-apps/books_downloader.git
synced 2025-12-06 06:55:37 +01:00
Refactor healthcheck
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
import os
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
response = httpx.get(
|
||||
"http://localhost:8080/healthcheck",
|
||||
headers={"Authorization": os.environ["API_KEY"]},
|
||||
"http://localhost:8080/healthcheck"
|
||||
)
|
||||
print(f"HEALTHCHECK STATUS: {response.status_code}")
|
||||
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)
|
||||
|
||||
|
||||
@router.get("/healthcheck")
|
||||
healthcheck_router = APIRouter(
|
||||
tags=["healthcheck"]
|
||||
)
|
||||
|
||||
|
||||
@healthcheck_router.get("/healthcheck")
|
||||
async def healthcheck():
|
||||
return "Ok!"
|
||||
|
||||
@@ -2,13 +2,14 @@ from fastapi import FastAPI
|
||||
|
||||
from prometheus_fastapi_instrumentator import Instrumentator
|
||||
|
||||
from app.views import router
|
||||
from app.views import router, healthcheck_router
|
||||
|
||||
|
||||
def start_app() -> FastAPI:
|
||||
app = FastAPI()
|
||||
|
||||
app.include_router(router)
|
||||
app.include_router(healthcheck_router)
|
||||
|
||||
Instrumentator().instrument(app).expose(app, include_in_schema=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user