mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 05:07:50 +02:00
Enable HC on driver
This commit is contained in:
@@ -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
20
dcc/driver/health.py
Normal 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"
|
Reference in New Issue
Block a user