Skip to content

Commit

Permalink
Confirmation webapp healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
f213 committed Jan 14, 2024
1 parent 362b3c8 commit a73ae62
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ CMD celery -A src.celery worker -c ${CONCURENCY:-4} -n "${celery}@%h" --max-task
#
FROM base as web
COPY --from=uwsgi-compile /uwsgi /usr/local/bin/
HEALTHCHECK CMD wget -q -O /dev/null http://localhost:8000/healthcheck/ || exit 1
CMD uwsgi --master --http :8000 --module src.web:app

3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ dev:

worker:
poetry run watchmedo auto-restart --directory src --patterns '*.py' --recursive -- celery -- -A src.celery worker --purge

web:
poetry run flask --app src.web run --debug --port 8090
10 changes: 10 additions & 0 deletions src/web.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import os

import kombu
from dotenv import load_dotenv
from flask import Flask, render_template

Expand All @@ -22,3 +25,10 @@ def confirm(key: str) -> str:
user.save()

return render_template("html/confirmation_ok.html")


@app.route("/healthcheck/")
def healthcheck() -> str:
with kombu.Connection(os.getenv("CELERY_BROKER_URL")) as connection:
connection.connect()
return "ok"

0 comments on commit a73ae62

Please sign in to comment.