From 437032ff236bda498d5766d9d73e00552fd20e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Thu, 18 Mar 2021 01:55:49 +0100 Subject: [PATCH] Add /_health/ URL for monitoring purposes --- WikiENS/urls.py | 17 ++++++++++------- WikiENS/views.py | 9 +++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 WikiENS/views.py diff --git a/WikiENS/urls.py b/WikiENS/urls.py index ceafd69..48e65f8 100644 --- a/WikiENS/urls.py +++ b/WikiENS/urls.py @@ -5,19 +5,22 @@ from allauth_ens.views import capture_login, capture_logout from wiki.urls import get_pattern as get_wiki_pattern from django_nyt.urls import get_pattern as get_nyt_pattern +from .views import HealthCheck + allauth_urls = [ # Catch login/logout views of admin site. - url(r'^_admin/login/$', capture_login), - url(r'^_admin/logout/$', capture_logout), + url(r"^_admin/login/$", capture_login), + url(r"^_admin/logout/$", capture_logout), # Allauth urls. - url(r'^_profil/', include('allauth.urls')), + url(r"^_profil/", include("allauth.urls")), ] urlpatterns = allauth_urls + [ - url(r'^_admin/', admin.site.urls), - url(r'^notifications/', get_nyt_pattern()), - url(r'^_groups/', include("wiki_groups.urls")), - url(r'', get_wiki_pattern()), + url(r"^_admin/", admin.site.urls), + url(r"^notifications/", get_nyt_pattern()), + url(r"^_groups/", include("wiki_groups.urls")), + url(r"^_health/", HealthCheck.as_view()), + url(r"", get_wiki_pattern()), ] # TODO add MEDIA_ROOT diff --git a/WikiENS/views.py b/WikiENS/views.py new file mode 100644 index 0000000..39aad9b --- /dev/null +++ b/WikiENS/views.py @@ -0,0 +1,9 @@ +from django.http import HttpResponse +from django.views import View + + +class HealthCheck(View): + http_method_names = ["get", "head"] + + def get(self, request, *args, **kwargs): + return HttpResponse("OK")