Add /health/ready endpoint

Fixes #98
This commit is contained in:
Klaas van Schelven
2025-05-12 13:42:50 +02:00
parent 78a95fb493
commit 4743e75019
2 changed files with 17 additions and 1 deletions

View File

@@ -13,7 +13,7 @@ from users.views import signup, confirm_email, resend_confirmation, request_rese
from ingest.views import download_envelope
from files.views import chunk_upload, artifact_bundle_assemble
from .views import home, trigger_error, favicon, settings_view, silence_email_system_warning, counts
from .views import home, trigger_error, favicon, settings_view, silence_email_system_warning, counts, health_check_ready
from .debug_views import csrf_debug
@@ -25,6 +25,8 @@ admin.site.index_title = "Admin" # everyone calls this the "admin" anyway. Let'
urlpatterns = [
path('', home, name='home'),
path("health/ready", health_check_ready, name="health_check_ready"),
path("accounts/signup/", signup, name="signup"),
path("accounts/resend-confirmation/", resend_confirmation, name="resend_confirmation"),
path("accounts/confirm-email/<str:token>/", confirm_email, name="confirm_email"),

View File

@@ -98,6 +98,20 @@ def home(request):
return redirect("team_list")
@login_exempt
def health_check_ready(request):
"""
A simple health check that returns 200 if the server is up and running. To be used in containerized environments
in a way that 'makes sense to you', e.g. as a readiness probe in Kubernetes.
What this "proves" is that the application server is up and accepting requests.
By design, this health check does not check the database connection; we only make a statement about _our own
health_; this is to avoid killing the app-server if the database is down.
"""
return HttpResponse("OK", content_type="text/plain")
@login_exempt
def trigger_error(request):
raise Exception("Exception triggered on purpose to debug error handling")