From b7b076be1e644b1a05d81950663a483ee37eaaea Mon Sep 17 00:00:00 2001 From: thenav56 Date: Sat, 15 Mar 2025 13:39:17 +0545 Subject: [PATCH] Add django-health-check --- main/settings.py | 11 +++++++++++ main/urls.py | 3 ++- pyproject.toml | 1 + uv.lock | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/main/settings.py b/main/settings.py index da6ea9b..4a94860 100644 --- a/main/settings.py +++ b/main/settings.py @@ -174,6 +174,13 @@ "django.contrib.staticfiles", # External "django_celery_beat", + # - Health-check + "health_check", # required + "health_check.db", + "health_check.cache", + "health_check.storage", + "health_check.contrib.migrations", + "health_check.contrib.redis", # requires Redis broker # Internal "apps.common", "apps.etl", @@ -363,6 +370,10 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" +# HEALTH-CHECK +REDIS_URL = CELERY_REDIS_URL +HEALTHCHECK_CACHE_KEY = "MONTY_ETL_HEALTHCHECK_KEY" + CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler" diff --git a/main/urls.py b/main/urls.py index f607863..a2a9021 100644 --- a/main/urls.py +++ b/main/urls.py @@ -18,10 +18,11 @@ from django.conf import settings from django.conf.urls.static import static from django.contrib import admin -from django.urls import path +from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), + path("health-check/", include("health_check.urls")), ] if settings.DEBUG: diff --git a/pyproject.toml b/pyproject.toml index d69c542..d7421a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,7 @@ dependencies = [ # Dev "django-stubs", "celery-types", + "django-health-check", ] [tool.uv.sources] diff --git a/uv.lock b/uv.lock index 6d0890e..d9072f6 100644 --- a/uv.lock +++ b/uv.lock @@ -430,6 +430,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/83/b3/0a3bec4ecbfee960f39b1842c2f91e4754251e0a6ed443db9fe3f666ba8f/django_environ-0.12.0-py2.py3-none-any.whl", hash = "sha256:92fb346a158abda07ffe6eb23135ce92843af06ecf8753f43adf9d2366dcc0ca", size = 19957 }, ] +[[package]] +name = "django-health-check" +version = "3.18.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "django" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/66/e9/0699ea3debfda75e5960ff99f56974136380e6f8202d453de7357e1f67fc/django_health_check-3.18.3.tar.gz", hash = "sha256:18b75daca4551c69a43f804f9e41e23f5f5fb9efd06cf6a313b3d5031bb87bd0", size = 20919 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e2/1e/3b23b580762cca7456427731de9b90718d15eec02ebe096437469d767dfe/django_health_check-3.18.3-py2.py3-none-any.whl", hash = "sha256:f5f58762b80bdf7b12fad724761993d6e83540f97e2c95c42978f187e452fa07", size = 30331 }, +] + [[package]] name = "django-redis" version = "5.4.0" @@ -917,6 +929,7 @@ dependencies = [ { name = "django" }, { name = "django-celery-beat" }, { name = "django-environ" }, + { name = "django-health-check" }, { name = "django-redis" }, { name = "django-storages", extra = ["azure", "s3"] }, { name = "django-stubs" }, @@ -944,6 +957,7 @@ requires-dist = [ { name = "django", specifier = ">=5.1.3,<6" }, { name = "django-celery-beat", specifier = ">=2.7.0,<3" }, { name = "django-environ" }, + { name = "django-health-check" }, { name = "django-redis", specifier = ">=5.4.0,<6" }, { name = "django-storages", extras = ["s3", "azure"], specifier = ">=1.14,<1.15" }, { name = "django-stubs" },