Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 1 addition & 39 deletions main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
"reversion",
# django-treebeard
"treebeard",
"health_check",
# Put our apps after this point
"main",
"authentication",
Expand Down Expand Up @@ -290,51 +291,12 @@
"drf_spectacular",
"mitol.apigateway.apps.ApigatewayApp",
"b2b",
"health_check",
"health_check.cache",
"health_check.contrib.migrations",
"health_check.contrib.celery_ping",
"health_check.contrib.redis",
"health_check.contrib.db_heartbeat",
"rest_framework_api_key",
)
# Only include the seed data app if this isn't running in prod
# if ENVIRONMENT not in ("production", "prod"):
# INSTALLED_APPS += ("localdev.seed",) # noqa: ERA001

HEALTH_CHECK = {
"SUBSETS": {
# The 'startup' subset includes checks that must pass before the application can
# start.
"startup": [
"MigrationsHealthCheck", # Ensures database migrations are applied.
"CacheBackend", # Verifies the cache backend is operational.
"RedisHealthCheck", # Confirms Redis is reachable and functional.
"DatabaseHeartBeatCheck", # Checks the database connection is alive.
],
# The 'liveness' subset includes checks to determine if the application is
# running.
"liveness": ["DatabaseHeartBeatCheck"], # Minimal check to ensure the app is
# alive.
# The 'readiness' subset includes checks to determine if the application is
# ready to serve requests.
"readiness": [
"CacheBackend", # Ensures the cache is ready for use.
"RedisHealthCheck", # Confirms Redis is ready for use.
"DatabaseHeartBeatCheck", # Verifies the database is ready for queries.
],
# The 'full' subset includes all available health checks for a comprehensive
# status report.
"full": [
"MigrationsHealthCheck", # Ensures database migrations are applied.
"CacheBackend", # Verifies the cache backend is operational.
"RedisHealthCheck", # Confirms Redis is reachable and functional.
"DatabaseHeartBeatCheck", # Checks the database connection is alive.
"CeleryPingHealthCheck", # Verifies Celery workers are responsive.
],
}
}

MIDDLEWARE = (
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
Expand Down
2 changes: 1 addition & 1 deletion main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
SpectacularSwaggerView.as_view(url_name="schema"),
name="swagger",
),
path("", include("main.urls_healthcheck")),
path("", include("authentication.urls")),
path("", include("openedx.urls")),
path("", include("mail.urls")),
Expand Down Expand Up @@ -90,7 +91,6 @@
re_path(r"^records/.*", index, {"noindex": True}, name="learner-records"),
re_path(r"^catalog/", index, name="catalog"),
path("api/instructor/<int:pk>/", instructor_page, name="cms_instructor_page"),
re_path(r"^health/", include("health_check.urls")),
# Wagtail
re_path(
r"^cms/login", cms_signin_redirect_to_site_signin, name="wagtailadmin_login"
Expand Down
59 changes: 59 additions & 0 deletions main/urls_healthcheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Healthcheck urls"""

from django.conf import settings
from django.urls import include, path, re_path
from health_check.views import HealthCheckView
from redis.asyncio import Redis as RedisClient

BASE_CHECKS = [
"health_check.Cache",
"health_check.Database",
(
"health_check.contrib.redis.Redis",
{"client_factory": lambda: RedisClient.from_url(settings.REDIS_URL)},
),
]


urlpatterns = [
path(
"health/",
include(
[
re_path(
r"startup\/?",
HealthCheckView.as_view(
checks=[
*BASE_CHECKS,
]
),
),
re_path(
r"liveness\/?",
HealthCheckView.as_view(
checks=[
"health_check.Database",
]
),
),
re_path(
r"readiness\/?",
HealthCheckView.as_view(
checks=[
*BASE_CHECKS,
]
),
),
re_path(
r"full\/?",
HealthCheckView.as_view(
checks=[
*BASE_CHECKS,
"health_check.contrib.celery.Ping",
]
),
),
]
),
),
]
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies = [
"django-cors-headers>=4.0.0,<5",
"django-countries>=7.2.1,<8",
"django-filter>=24.3,<25",
"django-health-check",
"django-health-check[celery,redis]>=4.0.0",
"django-hijack>=3.6.0,<4",
"django-ipware>=7.0.0,<8",
"django-redis>=6.0.0,<7",
Expand Down Expand Up @@ -119,9 +119,6 @@ dev = [
package = false
default-groups = "all"

[tool.uv.sources]
django-health-check = { git = "https://github.com/revsys/django-health-check", rev = "53f9bdc3a7acc8a577319987fef0bd3040eef4b4" } # pragma: allowlist secret

[tool.uv.build-backend]
module-root = ""

Expand Down
21 changes: 17 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.