Add healthcheck

This commit is contained in:
2022-02-04 12:53:44 +03:00
parent 924e5738a1
commit 9251b47cbf
3 changed files with 17 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ COPY --from=build-image $VENV_PATH $VENV_PATH
ENV PATH="$VENV_PATH/bin:$PATH"
COPY ./scripts/start_production.sh /root/
COPY ./scripts/healthcheck.py /root/
EXPOSE 8080

11
scripts/healthcheck.py Normal file
View File

@@ -0,0 +1,11 @@
import os
import httpx
response = httpx.get(
"http://localhost:8080/api/v1/healthcheck",
headers={"Authorization": os.environ["API_KEY"]},
)
print(f"HEALTHCHECK STATUS: {response.status_code}")
exit(0 if response.status_code == 200 else 1)

View File

@@ -108,3 +108,8 @@ async def update_cache(request: Request):
await arq_pool.enqueue_job("check_books")
return "Ok!"
@router.get("/healthcheck")
async def healthcheck():
return "Ok!"