From 6362bfa1231bb7d59aec8333dd01c5f78207567d Mon Sep 17 00:00:00 2001
From: Tom Teichler <tom.teichler@teckids.org>
Date: Tue, 5 May 2020 22:25:07 +0200
Subject: [PATCH] Install django-health-check

---
 aleksis/core/settings.py | 11 +++++++++++
 aleksis/core/urls.py     |  2 ++
 pyproject.toml           |  2 ++
 3 files changed, 15 insertions(+)

diff --git a/aleksis/core/settings.py b/aleksis/core/settings.py
index 22e831933..433ec235a 100644
--- a/aleksis/core/settings.py
+++ b/aleksis/core/settings.py
@@ -63,6 +63,11 @@ INSTALLED_APPS = [
     "polymorphic",
     "django_global_request",
     "dbbackup",
+    "health_check",
+    "health_check.db",
+    "health_check.cache",
+    "health_check.storage",
+    "health_check.contrib.psutil",
     "settings_context_processor",
     "sass_processor",
     "easyaudit",
@@ -648,6 +653,7 @@ elif HAYSTACK_BACKEND_SHORT == "whoosh":
 
 if _settings.get("celery.enabled", False) and _settings.get("search.celery", True):
     INSTALLED_APPS.append("celery_haystack")
+    INSTALLED_APPS.append("health_check.contrib.celery")
     HAYSTACK_SIGNAL_PROCESSOR = "celery_haystack.signals.CelerySignalProcessor"
 else:
     HAYSTACK_SIGNAL_PROCESSOR = "haystack.signals.RealtimeSignalProcessor"
@@ -655,3 +661,8 @@ else:
 HAYSTACK_SEARCH_RESULTS_PER_PAGE = 10
 
 DJANGO_EASY_AUDIT_WATCH_REQUEST_EVENTS = False
+
+HEALTH_CHECK = {
+    "DISK_USAGE_MAX": _settings.get("health.disk_usage_max_percent", 90),
+    "MEMORY_MIN": _settings.get("health.memory_min_mb", 500),
+}
diff --git a/aleksis/core/urls.py b/aleksis/core/urls.py
index ad35fa8c5..4fc624dc5 100644
--- a/aleksis/core/urls.py
+++ b/aleksis/core/urls.py
@@ -9,6 +9,7 @@ from django.views.i18n import JavaScriptCatalog
 import calendarweek.django
 import debug_toolbar
 from django_js_reverse.views import urls_js
+from health_check.urls import urlpatterns as health_urls
 from two_factor.urls import urlpatterns as tf_urls
 
 from . import views
@@ -119,6 +120,7 @@ urlpatterns = [
         {"registry_name": "group"},
         name="preferences_group",
     ),
+    path("health/", include(health_urls)),
 ]
 
 # Serve static files from STATIC_ROOT to make it work with runserver
diff --git a/pyproject.toml b/pyproject.toml
index 2e7e672f4..c23bc22b0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -85,6 +85,8 @@ spdx-license-list = "^0.4.0"
 license-expression = "^1.2"
 django-reversion = "^3.0.7"
 django-favicon-plus-reloaded = "^1.0.4"
+django-health-check = "^3.12.1"
+psutil = "^5.7.0"
 
 [tool.poetry.extras]
 ldap = ["django-auth-ldap"]
-- 
GitLab