没有项目描述
dj-healthchecks的Python项目详细描述
安装
pip install dj-healthchecks
用法
添加到项目
在urls.py
:
from django.conf.urls import url, include
from rest_framework import routers
from healthchecks.api import HealthViewSet
router = routers.DefaultRouter()
router.register(r'health', HealthViewSet, basename='health')
urlpatterns = [
path('admin/', admin.site.urls),
url(r'^', include(router.urls)),
]
在settings.py
HEALTH_CHECKS=['healthchecks.checks.im_ok','healthchecks.checks.connect_to_db','healthchecks.checks.connect_to_queue','healthchecks.checks.connect_to_redis','healthchecks.checks.ping_upstream_urls',...]
这个库提供了一些实用程序健康检查,但您也可以轻松编写自己的程序。
如果健康检查在healthchecks/checks.py
指定自己的健康检查:
HEALTH_CHECKS=[...'myapp.myodule.my_health_check',]
现在您有:
GET /health/ # run all health checks in settings.py
GET /health/some-health-check/ # run a specific healthcheck
注意:对于特定的健康检查,您-
将替换为.
运行项目:
docker-compose up
运行测试:
docker-compose run --rm web python manage.py test
利润。
更新
碰撞版本:
bumpversion manjor|minor|patch
按下“主控键”