From c4605f769453c16048b87ab5dfcd34ffee983708 Mon Sep 17 00:00:00 2001 From: Sudan Bhandari Date: Wed, 16 Oct 2024 11:30:56 +0545 Subject: [PATCH] Add Celery health check endpoint --- deep/settings.py | 8 ++++++++ deep/tests/test_case.py | 1 + deep/urls.py | 4 +++- poetry.lock | 23 +++++++++++++++++++++-- pyproject.toml | 1 + 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/deep/settings.py b/deep/settings.py index cc6b76b84d..1ed8058e4c 100644 --- a/deep/settings.py +++ b/deep/settings.py @@ -218,6 +218,14 @@ 'drf_yasg', # API Documentation 'graphene_django', 'graphene_graphiql_explorer', + # heath check + 'health_check', + 'health_check.db', # stock Django health checkers + 'health_check.cache', + 'health_check.storage', + 'health_check.contrib.migrations', + 'health_check.contrib.celery', # requires celery + 'health_check.contrib.celery_ping', # requires celery ] + [ '{}.{}.apps.{}Config'.format( APPS_DIR.split('/')[-1], diff --git a/deep/tests/test_case.py b/deep/tests/test_case.py index 54d34445c7..20433c7af0 100644 --- a/deep/tests/test_case.py +++ b/deep/tests/test_case.py @@ -11,6 +11,7 @@ from django.utils import timezone from django.conf import settings + from deep.middleware import _set_current_request as _set_middleware_current_request from user.models import User from project.models import ProjectRole, Project diff --git a/deep/urls.py b/deep/urls.py index 80fe97464e..8b298bb667 100644 --- a/deep/urls.py +++ b/deep/urls.py @@ -173,7 +173,7 @@ ProjectPublicVizView, PasswordChanged, get_frontend_url, - graphql_docs + graphql_docs, ) from organization.views import ( OrganizationViewSet, @@ -619,6 +619,8 @@ def get_api_path(path): name="favicon"), re_path('ses-bounce/?$', ses_bounce_handler_view, name='ses_bounce'), + re_path(r'health-check/', include('health_check.urls')), + ] + [ # graphql patterns re_path('^graphql/?$', csrf_exempt(CustomGraphQLView.as_view())), diff --git a/poetry.lock b/poetry.lock index a0c5dc5a36..b778e59fc0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "amqp" @@ -895,6 +895,24 @@ Django = ">=2.2" django-debug-toolbar = ">=3.1" graphene-django = ">=2.0.0" +[[package]] +name = "django-health-check" +version = "3.18.3" +description = "Run checks on services like databases, queue servers, celery processes, etc." +optional = false +python-versions = ">=3.8" +files = [ + {file = "django_health_check-3.18.3-py2.py3-none-any.whl", hash = "sha256:f5f58762b80bdf7b12fad724761993d6e83540f97e2c95c42978f187e452fa07"}, + {file = "django_health_check-3.18.3.tar.gz", hash = "sha256:18b75daca4551c69a43f804f9e41e23f5f5fb9efd06cf6a313b3d5031bb87bd0"}, +] + +[package.dependencies] +django = ">=2.2" + +[package.extras] +docs = ["sphinx"] +test = ["boto3", "celery", "django-storages", "pytest", "pytest-cov", "pytest-django", "redis"] + [[package]] name = "django-js-asset" version = "2.0.0" @@ -2840,6 +2858,7 @@ optional = false python-versions = ">=3.6" files = [ {file = "pytest-icdiff-0.6.tar.gz", hash = "sha256:e8f1ef4550a893b4f0a0ea7e7a8299b12ded72c086101d7811ddec0d85fd1bad"}, + {file = "pytest_icdiff-0.6-py3-none-any.whl", hash = "sha256:93ba20b71e51db7abecf99abee8fd13abd9ba7934f8e6838d1c4f443b4fc56a7"}, ] [package.dependencies] @@ -3769,4 +3788,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools" [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "5d64834a45fec04c0b4ca9436b71b3f79d774a2225ac8ad9c84cd06843599a81" +content-hash = "567353d5821c4240db9d7cf24dcf8a4f30f96d0147c3180f445fc909f97ba646" diff --git a/pyproject.toml b/pyproject.toml index 3265e8cb8f..70456883f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,6 +72,7 @@ django-environ = "^0.8.1" uwsgi = "*" django-admin-autocomplete-filter = "^0.7.1" aws-sns-message-validator = "0.0.5 " +django-health-check = "^3.18.3" # Thumbnail # Shapely = "==1.7.1"