Add health check endpoint

This commit is contained in:
Jared Szechy 2019-07-02 21:59:01 -04:00
parent 3da9af5a9f
commit 1964ab24f7
No known key found for this signature in database
GPG Key ID: E4188B1F15290E1A
4 changed files with 13 additions and 0 deletions

View File

@ -166,6 +166,9 @@ TIME_ZONE = 'UTC'
# database be configured and accessible by NetBox.
WEBHOOKS_ENABLED = False
# The health check endpoint reports if NetBox is operational, Set this to True to enable it.
HEALTH_CHECK_ENABLED = False
# Date/time formatting. See the following link for supported formats:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'N j, Y'

View File

@ -92,6 +92,7 @@ SHORT_TIME_FORMAT = getattr(configuration, 'SHORT_TIME_FORMAT', 'H:i:s')
TIME_FORMAT = getattr(configuration, 'TIME_FORMAT', 'g:i a')
TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
WEBHOOKS_ENABLED = getattr(configuration, 'WEBHOOKS_ENABLED', False)
HEALTH_CHECK_ENABLED = getattr(configuration, 'HEALTH_CHECK_ENABLED', False)
#
@ -189,6 +190,9 @@ INSTALLED_APPS = [
if WEBHOOKS_ENABLED:
INSTALLED_APPS.append('django_rq')
if HEALTH_CHECK_ENABLED:
INSTALLED_APPS.append('watchman')
# Middleware
MIDDLEWARE = (
'debug_toolbar.middleware.DebugToolbarMiddleware',

View File

@ -79,6 +79,11 @@ if settings.METRICS_ENABLED:
path('', include('django_prometheus.urls')),
]
if settings.HEALTH_CHECK_ENABLED:
_patterns += [
path(r'health/', include('watchman.urls')),
]
# Prepend BASE_PATH
urlpatterns = [
path(r'{}'.format(settings.BASE_PATH), include(_patterns))

View File

@ -10,6 +10,7 @@ django-tables2==2.0.6
django-taggit==1.1.0
django-taggit-serializer==0.1.7
django-timezone-field==3.0
django-watchman==0.17.0
djangorestframework==3.9.4
drf-yasg[validation]==1.16.0
graphviz==0.10.1