我们正在使用kuberntes,需要两个不同的端点,一个端点健康,一个端点活着。由于某些原因,我们选择https://github.com/KristianOellegaard/django-health-check。它很容易实现第二个 View ,该 View 已加载,但是
-此 View 为空
-我不了解如何配置 View 应使用的插件。
class AliveCheck(MainView):
# template_name = 'myapp/health_check_dashboard.html' # customize the used templates
def __init__(self):
self.plugins.clear()
self.plugins.append(DiskUsage())
def get(self, request, *args, **kwargs):
errors = super(MainView, self).run_check()
return super(MainView, self).get(request, args, kwargs)
有任何想法吗?
请您参考如下方法:
我们为我们找到了以下解决方案。不好,因为我们从父类(super class)访问内部属性-但它可以工作。
class AliveCheck(MainView):
def __init__(self):
self.plugins # force loading of configured plugins
self._plugins.clear() # remove all configured plugins
# append the plugins you are interested in
self._plugins.append(CacheBackend())
self._plugins.append(DefaultFileStorageHealthCheck())
self._plugins.append(DiskUsage())
self._plugins.append(MemoryUsage())




