diff --git a/data410/settings.py b/data410/settings.py index 767303e..f3c2fbb 100644 --- a/data410/settings.py +++ b/data410/settings.py @@ -67,6 +67,14 @@ "tailwind", "django_prose_editor", "adminsortable2", + # Health Check + "health_check", + "health_check.db", + "health_check.cache", + "health_check.storage", + "health_check.contrib.migrations", + "health_check.contrib.s3boto3_storage", + "health_check.contrib.redis", # XXX: Django Cleanup should be last "django_cleanup.apps.CleanupConfig", ] @@ -127,10 +135,12 @@ db_from_env = dj_database_url.config() DATABASES["default"].update(db_from_env) +REDIS_URL = os.environ.get("REDIS_URL", "redis://redis:6379/1") + CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": os.environ.get("REDIS_URL", default="redis://redis:6379/1"), + "LOCATION": REDIS_URL, "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", }, diff --git a/data410/urls.py b/data410/urls.py index b95c4f4..a31ee98 100644 --- a/data410/urls.py +++ b/data410/urls.py @@ -18,8 +18,10 @@ from django.conf import settings from django.conf.urls.static import static from django.contrib import admin +from django.contrib.admin.views.decorators import staff_member_required from django.contrib.sitemaps.views import sitemap from django.urls import path, include +from health_check.views import MainView from core.sitemaps import sitemaps from core.views import NotFoundView, ServerErrorView, RobotsView @@ -32,6 +34,7 @@ path("registry/", include("registry.urls")), path("", include("core.urls")), path("api/", include("api.urls")), + path("ht/", staff_member_required(MainView.as_view()), name="health_check"), path( "sitemap.xml", sitemap, diff --git a/requirements.txt b/requirements.txt index 6801f95..1fa398c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ Django==5.1.4 django-admin-sortable2==2.2.4 django-browser-reload==1.17.0 django-cleanup==9.0.0 +django-health-check==3.18.3 django-js-asset==3.0.1 django-prose-editor==0.10.2 django-redis==5.4.0