Enable HC on driver

This commit is contained in:
2022-01-05 12:19:42 +01:00
parent fa1bd1a73f
commit e9f129ac84
2 changed files with 25 additions and 0 deletions

View File

@@ -1,6 +1,11 @@
from django.apps import AppConfig
from health_check.plugins import plugin_dir
class DriverConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'driver'
def ready(self):
from driver.health import DriverHealthCheck
plugin_dir.register(DriverHealthCheck)

20
dcc/driver/health.py Normal file
View File

@@ -0,0 +1,20 @@
from health_check.backends import BaseHealthCheckBackend
from health_check.exceptions import (ServiceUnavailable,
ServiceReturnedUnexpectedResult)
from driver.connector import Connector
class DriverHealthCheck(BaseHealthCheckBackend):
critical_service = False
def check_status(self):
try:
Connector().passthrough(b'<s>')
except ConnectionRefusedError as e:
self.add_error(ServiceUnavailable("IOError"), e)
except Exception as e:
self.add_error(ServiceReturnedUnexpectedResult("IOError"), e)
def identifier(self):
return "DriverDaemon"