Skip to content

django-deploy-probes

このドキュメントは ドキュメントホーム の日本語訳です。

Django deployment probe endpoint を提供します。

インストール

pip install django-deploy-probes

Redis と Celery の readiness check は、extras として必要に応じてインストールできます。

pip install "django-deploy-probes[redis]"
pip install "django-deploy-probes[celery]"
pip install "django-deploy-probes[all]"

クイックスタート

Include 方式の URL 設定

from django.urls import include, path

urlpatterns = [
    path("", include("django_deploy_probes.urls")),
]

Import 方式の URL 設定

from django.urls import path
from django_deploy_probes.views import healthz, readyz, startupz, version

urlpatterns = [
    path("healthz/", healthz),
    path("readyz/", readyz),
    path("startupz/", startupz),
    path("version/", version),
]

/readyz のカスタム check メッセージはデフォルトで非表示です。EXPOSE_CHECK_MESSAGES=True を使う場合は、secret や機密情報をメッセージに含めないでください。

Security check はデフォルトで REMOTE_ADDR を使用します。Trusted reverse proxy の背後で probe にアクセスする場合は、TRUSTED_PROXY_NETWORKSCLIENT_IP_HEADER を設定して元の client IP を安全に判定してください。

ビルドと公開

ビルド

uv build

生成された distribution は dist/ に出力されます。

生成されるファイル:

  • dist/django_deploy_probes-0.3.1.tar.gz
  • dist/django_deploy_probes-0.3.1-py3-none-any.whl

インストールテスト

ビルド後、clean environment で wheel をインストールして確認します。

python -m venv /tmp/django-deploy-probes-install-test
source /tmp/django-deploy-probes-install-test/bin/activate
pip install dist/django_deploy_probes-0.3.1-py3-none-any.whl
python -c "import django_deploy_probes; print(django_deploy_probes.__version__)"

PyPI への公開

GitHub Release を公開すると、.github/workflows/publish.yml が PyPI Trusted Publishing で公開します。

英語ドキュメントホームに戻る