From ec167d4e9cb04765ab1c065e997bf17b0289d0be Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Sat, 21 Feb 2026 20:24:33 +0300 Subject: [PATCH] refactor(health-check): replace default views with custom configuration migrated health check configuration to custom settings for more precise control. Removed unused `health_check` submodules to streamline dependencies. Updated URLs to use `HealthCheckView` with tailored checks. Streamlines health monitoring and reduces unnecessary bloat. --- schon/settings/base.py | 9 --------- schon/urls.py | 25 ++++++++++++++++++++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/schon/settings/base.py b/schon/settings/base.py index 0ea95c1a..eda7898f 100644 --- a/schon/settings/base.py +++ b/schon/settings/base.py @@ -128,15 +128,6 @@ INSTALLED_APPS: list[str] = [ "django.contrib.gis", "django.contrib.humanize", "health_check", - "health_check.db", - "health_check.cache", - "health_check.storage", - "health_check.contrib.migrations", - "health_check.contrib.celery_ping", - "health_check.contrib.psutil", - "health_check.contrib.redis", - "health_check.contrib.db_heartbeat", - "health_check.contrib.mail", "cacheops", "django_celery_beat", "django_celery_results", diff --git a/schon/urls.py b/schon/urls.py index 380d3613..6b7f6c49 100644 --- a/schon/urls.py +++ b/schon/urls.py @@ -3,6 +3,8 @@ from django.conf.urls.static import static from django.contrib import admin from django.urls import include, path from django.views.decorators.csrf import csrf_exempt +from health_check.views import HealthCheckView +from redis.asyncio import Redis as RedisClient from engine.core.graphene.schema import schema from engine.core.views import ( @@ -21,9 +23,26 @@ urlpatterns = [ index, ), path( - r"health/", - include( - "health_check.urls", + "health/", + HealthCheckView.as_view( + checks=[ + "health_check.Cache", + "health_check.DNS", + "health_check.Database", + "health_check.Mail", + "health_check.Storage", + "health_check.contrib.psutil.Disk", + "health_check.contrib.psutil.Memory", + "health_check.contrib.celery.Ping", + ( + "health_check.contrib.redis.Redis", + { + "client_factory": lambda: RedisClient.from_url( + settings.CELERY_BROKER_URL + ) + }, + ), + ], ), ), path(