django-deploy-probes 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_deploy_probes-0.1.0/.gitignore +14 -0
- django_deploy_probes-0.1.0/CHANGELOG.md +183 -0
- django_deploy_probes-0.1.0/CODE_OF_CONDUCT.md +20 -0
- django_deploy_probes-0.1.0/CONTRIBUTING.md +26 -0
- django_deploy_probes-0.1.0/LICENSE +21 -0
- django_deploy_probes-0.1.0/PKG-INFO +276 -0
- django_deploy_probes-0.1.0/README.md +229 -0
- django_deploy_probes-0.1.0/SECURITY.md +20 -0
- django_deploy_probes-0.1.0/SUPPORT.md +23 -0
- django_deploy_probes-0.1.0/django_deploy_probes/__init__.py +5 -0
- django_deploy_probes-0.1.0/django_deploy_probes/apps.py +9 -0
- django_deploy_probes-0.1.0/django_deploy_probes/checks/__init__.py +1 -0
- django_deploy_probes-0.1.0/django_deploy_probes/checks/celery.py +85 -0
- django_deploy_probes-0.1.0/django_deploy_probes/checks/custom.py +44 -0
- django_deploy_probes-0.1.0/django_deploy_probes/checks/database.py +21 -0
- django_deploy_probes-0.1.0/django_deploy_probes/checks/migrations.py +22 -0
- django_deploy_probes-0.1.0/django_deploy_probes/checks/redis.py +35 -0
- django_deploy_probes-0.1.0/django_deploy_probes/checks/registry.py +70 -0
- django_deploy_probes-0.1.0/django_deploy_probes/checks/results.py +33 -0
- django_deploy_probes-0.1.0/django_deploy_probes/conf.py +64 -0
- django_deploy_probes-0.1.0/django_deploy_probes/django_checks.py +174 -0
- django_deploy_probes-0.1.0/django_deploy_probes/openapi.py +184 -0
- django_deploy_probes-0.1.0/django_deploy_probes/security.py +43 -0
- django_deploy_probes-0.1.0/django_deploy_probes/urls.py +13 -0
- django_deploy_probes-0.1.0/django_deploy_probes/views.py +104 -0
- django_deploy_probes-0.1.0/docs/api.md +138 -0
- django_deploy_probes-0.1.0/docs/basic.md +146 -0
- django_deploy_probes-0.1.0/docs/comparison.md +23 -0
- django_deploy_probes-0.1.0/docs/docker-compose.md +205 -0
- django_deploy_probes-0.1.0/docs/docker.md +164 -0
- django_deploy_probes-0.1.0/docs/ja.md +81 -0
- django_deploy_probes-0.1.0/docs/ko.md +81 -0
- django_deploy_probes-0.1.0/docs/kubernetes.md +148 -0
- django_deploy_probes-0.1.0/docs/recipes/aws-ecs-alb.md +34 -0
- django_deploy_probes-0.1.0/docs/recipes/github-actions.md +43 -0
- django_deploy_probes-0.1.0/docs/recipes/nginx-blue-green.md +20 -0
- django_deploy_probes-0.1.0/docs/security.md +155 -0
- django_deploy_probes-0.1.0/docs/tutorial.md +24 -0
- django_deploy_probes-0.1.0/docs/zh-CN.md +81 -0
- django_deploy_probes-0.1.0/examples/basic/README.md +22 -0
- django_deploy_probes-0.1.0/examples/basic/config/__init__.py +1 -0
- django_deploy_probes-0.1.0/examples/basic/config/settings.py +38 -0
- django_deploy_probes-0.1.0/examples/basic/config/urls.py +6 -0
- django_deploy_probes-0.1.0/examples/basic/manage.py +14 -0
- django_deploy_probes-0.1.0/examples/docker/Dockerfile +31 -0
- django_deploy_probes-0.1.0/examples/docker/README.md +16 -0
- django_deploy_probes-0.1.0/examples/docker/config/__init__.py +1 -0
- django_deploy_probes-0.1.0/examples/docker/config/settings.py +40 -0
- django_deploy_probes-0.1.0/examples/docker/config/urls.py +6 -0
- django_deploy_probes-0.1.0/examples/docker/config/wsgi.py +8 -0
- django_deploy_probes-0.1.0/examples/docker/manage.py +14 -0
- django_deploy_probes-0.1.0/examples/docker-compose/Dockerfile +24 -0
- django_deploy_probes-0.1.0/examples/docker-compose/README.md +25 -0
- django_deploy_probes-0.1.0/examples/docker-compose/config/__init__.py +1 -0
- django_deploy_probes-0.1.0/examples/docker-compose/config/settings.py +46 -0
- django_deploy_probes-0.1.0/examples/docker-compose/config/urls.py +6 -0
- django_deploy_probes-0.1.0/examples/docker-compose/config/wsgi.py +8 -0
- django_deploy_probes-0.1.0/examples/docker-compose/docker-compose.yml +31 -0
- django_deploy_probes-0.1.0/examples/docker-compose/manage.py +14 -0
- django_deploy_probes-0.1.0/examples/kubernetes/README.md +18 -0
- django_deploy_probes-0.1.0/examples/kubernetes/deployment.yaml +62 -0
- django_deploy_probes-0.1.0/examples/kubernetes/service.yaml +12 -0
- django_deploy_probes-0.1.0/examples/security/README.md +21 -0
- django_deploy_probes-0.1.0/examples/security/config/__init__.py +1 -0
- django_deploy_probes-0.1.0/examples/security/config/settings.py +44 -0
- django_deploy_probes-0.1.0/examples/security/config/urls.py +6 -0
- django_deploy_probes-0.1.0/examples/security/manage.py +14 -0
- django_deploy_probes-0.1.0/pyproject.toml +119 -0
- django_deploy_probes-0.1.0/tests/__init__.py +1 -0
- django_deploy_probes-0.1.0/tests/conftest.py +7 -0
- django_deploy_probes-0.1.0/tests/import_urls.py +10 -0
- django_deploy_probes-0.1.0/tests/settings.py +12 -0
- django_deploy_probes-0.1.0/tests/test_conf.py +32 -0
- django_deploy_probes-0.1.0/tests/test_django_checks.py +40 -0
- django_deploy_probes-0.1.0/tests/test_healthz.py +33 -0
- django_deploy_probes-0.1.0/tests/test_import_usage.py +56 -0
- django_deploy_probes-0.1.0/tests/test_openapi.py +113 -0
- django_deploy_probes-0.1.0/tests/test_readyz.py +741 -0
- django_deploy_probes-0.1.0/tests/test_security.py +114 -0
- django_deploy_probes-0.1.0/tests/test_startupz.py +118 -0
- django_deploy_probes-0.1.0/tests/test_version.py +76 -0
- django_deploy_probes-0.1.0/tests/urls.py +6 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## v0.1.0 - Initial Release
|
|
4
|
+
|
|
5
|
+
`django-deploy-probes` provides lightweight deployment probe endpoints for Django applications.
|
|
6
|
+
|
|
7
|
+
This release is focused on deployment validation workflows such as blue/green deployments, rolling deployments, Kubernetes probes, Docker health checks, Nginx upstream switching, and CI/CD verification.
|
|
8
|
+
|
|
9
|
+
### Highlights
|
|
10
|
+
|
|
11
|
+
- Add `healthz` endpoint for process liveness checks.
|
|
12
|
+
- Add `readyz` endpoint for traffic readiness checks.
|
|
13
|
+
- Add `startupz` endpoint for startup/bootstrap checks.
|
|
14
|
+
- Add `version` endpoint for deployed application metadata.
|
|
15
|
+
- Support both include-style and import-style Django URL configuration.
|
|
16
|
+
- Support optional readiness checks for Django databases, Redis, Celery, migrations, and custom checks.
|
|
17
|
+
- Add optional package extras for Redis and Celery integrations.
|
|
18
|
+
- Add basic probe access controls for internal IP and header token validation.
|
|
19
|
+
- Add configurable internal IP networks, secret-safe custom check messages, and optional safe
|
|
20
|
+
failure reasons.
|
|
21
|
+
- Add GitHub Actions CI and Trusted Publishing release workflow.
|
|
22
|
+
|
|
23
|
+
### Installation
|
|
24
|
+
|
|
25
|
+
Install the base package:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install django-deploy-probes
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Install optional Redis and Celery readiness check dependencies:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install "django-deploy-probes[redis]"
|
|
35
|
+
pip install "django-deploy-probes[celery]"
|
|
36
|
+
pip install "django-deploy-probes[all]"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Quick Start
|
|
40
|
+
|
|
41
|
+
Include all probe URLs:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from django.urls import include, path
|
|
45
|
+
|
|
46
|
+
urlpatterns = [
|
|
47
|
+
path("", include("django_deploy_probes.urls")),
|
|
48
|
+
]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This exposes:
|
|
52
|
+
|
|
53
|
+
- `GET /healthz`
|
|
54
|
+
- `GET /readyz`
|
|
55
|
+
- `GET /startupz`
|
|
56
|
+
- `GET /version`
|
|
57
|
+
|
|
58
|
+
Alternatively, import the views directly:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from django.urls import path
|
|
62
|
+
from django_deploy_probes.views import healthz, readyz, startupz, version
|
|
63
|
+
|
|
64
|
+
urlpatterns = [
|
|
65
|
+
path("healthz/", healthz),
|
|
66
|
+
path("readyz/", readyz),
|
|
67
|
+
path("startupz/", startupz),
|
|
68
|
+
path("version/", version),
|
|
69
|
+
]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Configure deployment metadata and readiness checks in Django settings:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
DEPLOY_PROBES = {
|
|
76
|
+
"SERVICE_NAME": "my-django-app",
|
|
77
|
+
"ENVIRONMENT": "prod",
|
|
78
|
+
"VERSION": "1.2.0",
|
|
79
|
+
"COMMIT": "a1b2c3d",
|
|
80
|
+
"BRANCH": "main",
|
|
81
|
+
"BUILD_TIME": "2026-05-13T10:00:00+09:00",
|
|
82
|
+
"SLOT": "green",
|
|
83
|
+
"READY_CHECKS": [
|
|
84
|
+
"database",
|
|
85
|
+
"redis",
|
|
86
|
+
"celery",
|
|
87
|
+
],
|
|
88
|
+
"DATABASES": [
|
|
89
|
+
"default",
|
|
90
|
+
],
|
|
91
|
+
"REDIS": {
|
|
92
|
+
"default": {
|
|
93
|
+
"LOCATION": "redis://localhost:6379/0",
|
|
94
|
+
"TIMEOUT": 1.0,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
"CELERY": {
|
|
98
|
+
"BROKER": True,
|
|
99
|
+
"WORKERS": False,
|
|
100
|
+
"RESULT_BACKEND": False,
|
|
101
|
+
"TIMEOUT": 1.0,
|
|
102
|
+
},
|
|
103
|
+
"DETAIL_LEVEL": "none",
|
|
104
|
+
"EXPOSE_CHECK_MESSAGES": False,
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Endpoint Behavior
|
|
109
|
+
|
|
110
|
+
`GET /healthz` returns `200` when the Django process is alive:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"status": "ok"
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`GET /readyz` returns `200` when all enabled readiness checks pass:
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"status": "ready",
|
|
123
|
+
"checks": {
|
|
124
|
+
"database.default": "ok",
|
|
125
|
+
"redis.default": "ok",
|
|
126
|
+
"celery.broker": "ok"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`GET /readyz` returns `503` when any enabled readiness check fails:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"status": "not_ready",
|
|
136
|
+
"checks": {
|
|
137
|
+
"database.default": "ok",
|
|
138
|
+
"redis.default": "fail",
|
|
139
|
+
"celery.broker": "ok"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
`GET /version` returns configured deployment metadata:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"service": "my-django-app",
|
|
149
|
+
"environment": "prod",
|
|
150
|
+
"version": "1.2.0",
|
|
151
|
+
"commit": "a1b2c3d",
|
|
152
|
+
"branch": "main",
|
|
153
|
+
"build_time": "2026-05-13T10:00:00+09:00",
|
|
154
|
+
"slot": "green"
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Supported Versions
|
|
159
|
+
|
|
160
|
+
- Python: 3.9+
|
|
161
|
+
- Django: 4.2+
|
|
162
|
+
- Redis extra: `redis>=4.5`
|
|
163
|
+
- Celery extra: `celery>=5.3`
|
|
164
|
+
|
|
165
|
+
Package classifiers include Python 3.9 through 3.14 and Django 4.2 / 5.x.
|
|
166
|
+
|
|
167
|
+
### Known Limitations
|
|
168
|
+
|
|
169
|
+
- `healthz` is intentionally minimal and does not check databases, cache, Redis, Celery, migrations, or external services.
|
|
170
|
+
- `readyz` only checks dependencies that are explicitly enabled in `DEPLOY_PROBES["READY_CHECKS"]`.
|
|
171
|
+
- Redis and Celery checks require installing the corresponding optional extras.
|
|
172
|
+
- Security checks use `REMOTE_ADDR` by default and do not trust `X-Forwarded-For`; configure trusted proxy handling separately at the application or infrastructure layer.
|
|
173
|
+
- Custom readiness check messages are hidden by default; do not include secrets or sensitive values
|
|
174
|
+
if `EXPOSE_CHECK_MESSAGES=True`.
|
|
175
|
+
- This package is not a metrics, tracing, APM, or full monitoring system.
|
|
176
|
+
|
|
177
|
+
### Next Version Plans
|
|
178
|
+
|
|
179
|
+
- Expand documentation for production deployment patterns.
|
|
180
|
+
- Add more examples for Kubernetes, Docker, Nginx, and CI/CD validation.
|
|
181
|
+
- Add more examples for custom readiness checks.
|
|
182
|
+
- Consider richer readiness check result details while keeping secret-safe defaults.
|
|
183
|
+
- Continue compatibility testing across supported Python and Django versions.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We want `django-deploy-probes` to be a respectful and useful project for maintainers, contributors, and users.
|
|
6
|
+
|
|
7
|
+
Participants are expected to communicate clearly, assume good intent, and focus technical discussions on the work.
|
|
8
|
+
|
|
9
|
+
## Unacceptable Behavior
|
|
10
|
+
|
|
11
|
+
- Harassment, threats, or personal attacks.
|
|
12
|
+
- Publicly sharing private information without permission.
|
|
13
|
+
- Sustained disruption of project discussions.
|
|
14
|
+
- Dismissive or hostile behavior toward new contributors.
|
|
15
|
+
|
|
16
|
+
## Enforcement
|
|
17
|
+
|
|
18
|
+
Report conduct concerns privately to the maintainer listed in `pyproject.toml`.
|
|
19
|
+
|
|
20
|
+
Maintainers may remove comments, close issues, block accounts, or take other reasonable action to protect the project.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping improve `django-deploy-probes`.
|
|
4
|
+
|
|
5
|
+
## Local setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv sync --dev
|
|
9
|
+
uv run pytest -q
|
|
10
|
+
uv run ruff check .
|
|
11
|
+
uv build
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Development guidelines
|
|
15
|
+
|
|
16
|
+
- Keep `/healthz` lightweight. It must not touch databases, caches, Redis, Celery, or external services.
|
|
17
|
+
- Keep readiness failures secret-safe by default.
|
|
18
|
+
- Add or update tests for behavior changes.
|
|
19
|
+
- Update README or docs when public settings, endpoints, or response shapes change.
|
|
20
|
+
|
|
21
|
+
## Release checklist
|
|
22
|
+
|
|
23
|
+
1. Update the version in `django_deploy_probes/__init__.py`.
|
|
24
|
+
2. Update `CHANGELOG.md`.
|
|
25
|
+
3. Run tests, lint, and build locally.
|
|
26
|
+
4. Create a GitHub release. The publish workflow uses PyPI Trusted Publishing.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 django-deploy-probes contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-deploy-probes
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deployment probe endpoints for Django applications.
|
|
5
|
+
Project-URL: Homepage, https://github.com/emfpdlzj/django-deploy-probes
|
|
6
|
+
Project-URL: Repository, https://github.com/emfpdlzj/django-deploy-probes
|
|
7
|
+
Project-URL: Issues, https://github.com/emfpdlzj/django-deploy-probes/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/emfpdlzj/django-deploy-probes#readme
|
|
9
|
+
Project-URL: Changelog, https://github.com/emfpdlzj/django-deploy-probes/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: emfpdlzj <redryan@ajou.ac.kr>
|
|
11
|
+
Maintainer-email: emfpdlzj <redryan@ajou.ac.kr>
|
|
12
|
+
License-Expression: MIT
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: deployment,django,healthcheck,kubernetes,probe,readiness
|
|
15
|
+
Classifier: Development Status :: 3 - Alpha
|
|
16
|
+
Classifier: Environment :: Web Environment
|
|
17
|
+
Classifier: Framework :: Django
|
|
18
|
+
Classifier: Framework :: Django :: 4.2
|
|
19
|
+
Classifier: Framework :: Django :: 5
|
|
20
|
+
Classifier: Intended Audience :: Developers
|
|
21
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
22
|
+
Classifier: Operating System :: OS Independent
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
29
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
30
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
31
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
32
|
+
Requires-Python: >=3.9
|
|
33
|
+
Requires-Dist: django>=4.2
|
|
34
|
+
Provides-Extra: all
|
|
35
|
+
Requires-Dist: celery>=5.3; extra == 'all'
|
|
36
|
+
Requires-Dist: djangorestframework>=3.14; extra == 'all'
|
|
37
|
+
Requires-Dist: drf-spectacular>=0.27; extra == 'all'
|
|
38
|
+
Requires-Dist: redis>=4.5; extra == 'all'
|
|
39
|
+
Provides-Extra: celery
|
|
40
|
+
Requires-Dist: celery>=5.3; extra == 'celery'
|
|
41
|
+
Provides-Extra: openapi
|
|
42
|
+
Requires-Dist: djangorestframework>=3.14; extra == 'openapi'
|
|
43
|
+
Requires-Dist: drf-spectacular>=0.27; extra == 'openapi'
|
|
44
|
+
Provides-Extra: redis
|
|
45
|
+
Requires-Dist: redis>=4.5; extra == 'redis'
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
# django-deploy-probes
|
|
49
|
+
|
|
50
|
+
Production-ready HTTP deployment probe endpoints for Django applications. Unlike `django-probes`, this package does not provide management commands; it exposes lightweight `/healthz`, `/readyz`, `/startupz`, and `/version` views for runtime deployment checks.
|
|
51
|
+
|
|
52
|
+
Use these endpoints for CI/CD, Docker, Kubernetes, and blue-green deployments.
|
|
53
|
+
|
|
54
|
+
[](https://pypi.org/project/django-deploy-probes/)
|
|
55
|
+
[](https://www.python.org/)
|
|
56
|
+
[](https://www.djangoproject.com/)
|
|
57
|
+
[](LICENSE)
|
|
58
|
+
[](https://docs.astral.sh/uv/)
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
- Lightweight `healthz` endpoint for liveness checks.
|
|
63
|
+
- Dependency-aware `readyz` endpoint for deployment readiness checks.
|
|
64
|
+
- `startupz` endpoint for startup/bootstrap checks such as pending migrations.
|
|
65
|
+
- `version` endpoint for validating service metadata, with optional build details when explicitly enabled.
|
|
66
|
+
- Optional Redis, Celery, migration, and custom readiness checks for production deployments.
|
|
67
|
+
- Secret-safe response defaults, with optional safe failure reasons and check durations for CI/CD debugging.
|
|
68
|
+
|
|
69
|
+
## Quick Start
|
|
70
|
+
|
|
71
|
+
- [Install the package](#installation)
|
|
72
|
+
- [Configure Django URLs](#include-style-url-configuration)
|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install django-deploy-probes
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Optional Redis and Celery readiness checks are available as extras:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install "django-deploy-probes[redis]"
|
|
84
|
+
pip install "django-deploy-probes[celery]"
|
|
85
|
+
pip install "django-deploy-probes[all]"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Optional Swagger/OpenAPI documentation support is available as a separate extra:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install "django-deploy-probes[openapi]"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Include-style URL configuration
|
|
95
|
+
|
|
96
|
+
Add the app so Django system checks can validate your probe settings:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
INSTALLED_APPS = [
|
|
100
|
+
"django_deploy_probes",
|
|
101
|
+
]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from django.urls import include, path
|
|
106
|
+
|
|
107
|
+
urlpatterns = [
|
|
108
|
+
path("", include("django_deploy_probes.urls")),
|
|
109
|
+
]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Import-style URL configuration
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from django.urls import path
|
|
116
|
+
from django_deploy_probes.views import healthz, readyz, startupz, version
|
|
117
|
+
|
|
118
|
+
urlpatterns = [
|
|
119
|
+
path("healthz", healthz),
|
|
120
|
+
path("readyz", readyz),
|
|
121
|
+
path("startupz", startupz),
|
|
122
|
+
path("version", version),
|
|
123
|
+
]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Custom check messages are hidden by default. If you enable `EXPOSE_CHECK_MESSAGES=True`, do not include secrets or sensitive values in those messages.
|
|
127
|
+
|
|
128
|
+
Security checks use `REMOTE_ADDR` by default and do not trust `X-Forwarded-For`; configure your reverse proxy separately when probes are accessed through a proxy.
|
|
129
|
+
|
|
130
|
+
### Common settings
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
DEPLOY_PROBES = {
|
|
134
|
+
"SERVICE_NAME": "my-django-app",
|
|
135
|
+
"ENVIRONMENT": "prod",
|
|
136
|
+
"VERSION": "1.2.0",
|
|
137
|
+
"READY_CHECKS": ["database", "redis", "celery"],
|
|
138
|
+
"STARTUP_CHECKS": ["migrations"],
|
|
139
|
+
"READY_CUSTOM_CHECKS": [],
|
|
140
|
+
"STARTUP_CUSTOM_CHECKS": [],
|
|
141
|
+
"DATABASES": ["default"],
|
|
142
|
+
"REDIS": {
|
|
143
|
+
"default": {
|
|
144
|
+
"LOCATION": "redis://localhost:6379/0",
|
|
145
|
+
"TIMEOUT": 1.0,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
"CELERY": {
|
|
149
|
+
"BROKER": True,
|
|
150
|
+
"WORKERS": False,
|
|
151
|
+
"RESULT_BACKEND": False,
|
|
152
|
+
"TIMEOUT": 1.0,
|
|
153
|
+
},
|
|
154
|
+
"DETAIL_LEVEL": "none",
|
|
155
|
+
"INCLUDE_CHECK_DURATIONS": False,
|
|
156
|
+
"REQUIRE_READY_CHECKS": False,
|
|
157
|
+
"REQUIRE_STARTUP_CHECKS": False,
|
|
158
|
+
"EXPOSE_CHECK_MESSAGES": False,
|
|
159
|
+
"INTERNAL_IP_ONLY": False,
|
|
160
|
+
"INTERNAL_IP_NETWORKS": [
|
|
161
|
+
"127.0.0.1/32",
|
|
162
|
+
"::1/128",
|
|
163
|
+
"10.0.0.0/8",
|
|
164
|
+
"172.16.0.0/12",
|
|
165
|
+
"192.168.0.0/16",
|
|
166
|
+
],
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Set `DETAIL_LEVEL="safe"` to include stable failure reasons such as
|
|
171
|
+
`redis_package_missing` or `unapplied_migrations`.
|
|
172
|
+
|
|
173
|
+
Set `INCLUDE_CHECK_DURATIONS=True` to wrap each check result with a `status` and
|
|
174
|
+
`duration_ms` value. This is useful in CI/CD diagnostics, but keep it disabled if
|
|
175
|
+
you want the smallest possible response body.
|
|
176
|
+
|
|
177
|
+
## Optional Swagger/OpenAPI
|
|
178
|
+
|
|
179
|
+
Probe endpoints are not added to Swagger/OpenAPI documentation by default. They are operational endpoints and should normally stay internal or be protected with the package security options documented in [Security options](docs/security.md).
|
|
180
|
+
|
|
181
|
+
To document `/healthz`, `/readyz`, `/startupz`, and `/version` with drf-spectacular, install the OpenAPI extra:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
pip install "django-deploy-probes[openapi]"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Enable probe documentation explicitly in `settings.py`:
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
INSTALLED_APPS = [
|
|
191
|
+
"django_deploy_probes",
|
|
192
|
+
"rest_framework",
|
|
193
|
+
"drf_spectacular",
|
|
194
|
+
]
|
|
195
|
+
|
|
196
|
+
REST_FRAMEWORK = {
|
|
197
|
+
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
DEPLOY_PROBES = {
|
|
201
|
+
"ENABLE_OPENAPI": True,
|
|
202
|
+
"OPENAPI_TAG": "Deployment Probes",
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Add drf-spectacular schema and Swagger UI URLs in your project `urls.py`:
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from django.urls import include, path
|
|
210
|
+
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
|
|
211
|
+
|
|
212
|
+
urlpatterns = [
|
|
213
|
+
path("", include("django_deploy_probes.urls")),
|
|
214
|
+
path("api/schema/", SpectacularAPIView.as_view(), name="schema"),
|
|
215
|
+
path(
|
|
216
|
+
"api/docs/",
|
|
217
|
+
SpectacularSwaggerView.as_view(url_name="schema"),
|
|
218
|
+
name="swagger-ui",
|
|
219
|
+
),
|
|
220
|
+
]
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
If `ENABLE_OPENAPI=True` but drf-spectacular is not installed, the probe views continue to work without schema metadata. drf-yasg is not implemented in this phase and is reserved for future compatibility work.
|
|
224
|
+
|
|
225
|
+
## Tutorials
|
|
226
|
+
|
|
227
|
+
- [Tutorial index](docs/tutorial.md)
|
|
228
|
+
- [Basic setup](docs/basic.md)
|
|
229
|
+
- [Docker integration](docs/docker.md)
|
|
230
|
+
- [Docker Compose integration](docs/docker-compose.md)
|
|
231
|
+
- [Kubernetes probes](docs/kubernetes.md)
|
|
232
|
+
- [API reference](docs/api.md)
|
|
233
|
+
- [Security options](docs/security.md)
|
|
234
|
+
- [Comparison with django-probes](docs/comparison.md)
|
|
235
|
+
- [GitHub Actions deployment validation](docs/recipes/github-actions.md)
|
|
236
|
+
- [Nginx blue-green switching](docs/recipes/nginx-blue-green.md)
|
|
237
|
+
- [AWS ECS/ALB health checks](docs/recipes/aws-ecs-alb.md)
|
|
238
|
+
|
|
239
|
+
## Runnable Examples
|
|
240
|
+
|
|
241
|
+
- [Basic example](examples/basic)
|
|
242
|
+
- [Docker example](examples/docker)
|
|
243
|
+
- [Docker Compose example](examples/docker-compose)
|
|
244
|
+
- [Kubernetes example](examples/kubernetes)
|
|
245
|
+
- [Security example](examples/security)
|
|
246
|
+
|
|
247
|
+
## Build and Publish
|
|
248
|
+
|
|
249
|
+
### Build
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
uv build
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Generated distributions are written to `dist/`.
|
|
256
|
+
|
|
257
|
+
Generated files:
|
|
258
|
+
|
|
259
|
+
- `dist/django_deploy_probes-0.1.0.tar.gz`
|
|
260
|
+
- `dist/django_deploy_probes-0.1.0-py3-none-any.whl`
|
|
261
|
+
|
|
262
|
+
### Installation Test
|
|
263
|
+
|
|
264
|
+
After building, install the wheel in a clean environment:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
python -m venv /tmp/django-deploy-probes-install-test
|
|
268
|
+
source /tmp/django-deploy-probes-install-test/bin/activate
|
|
269
|
+
pip install dist/django_deploy_probes-0.1.0-py3-none-any.whl
|
|
270
|
+
python -c "import django_deploy_probes; print(django_deploy_probes.__version__)"
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### PyPI Publish
|
|
274
|
+
|
|
275
|
+
Publishing is handled by `.github/workflows/publish.yml` when a GitHub release is published.
|
|
276
|
+
Configure PyPI Trusted Publishing for the repository before the first release.
|