feat(ops): add /healthz endpoint and container healthcheck
Expose a lightweight /healthz route on the main aiohttp server and wire docker-compose healthcheck so orchestrators can detect failures.
This commit is contained in:
@@ -58,6 +58,11 @@ async def build_and_start_web_app(
|
|||||||
app = web.Application()
|
app = web.Application()
|
||||||
_inject_shared_instances(app, dp, bot, settings, async_session_factory)
|
_inject_shared_instances(app, dp, bot, settings, async_session_factory)
|
||||||
|
|
||||||
|
async def _healthcheck(request: web.Request) -> web.Response:
|
||||||
|
return web.json_response({"status": "ok"})
|
||||||
|
|
||||||
|
app.router.add_get("/healthz", _healthcheck)
|
||||||
|
|
||||||
setup_application(app, dp, bot=bot)
|
setup_application(app, dp, bot=bot)
|
||||||
|
|
||||||
telegram_uses_webhook_mode = bool(settings.WEBHOOK_BASE_URL)
|
telegram_uses_webhook_mode = bool(settings.WEBHOOK_BASE_URL)
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 127.0.0.1:8080:8080
|
- 127.0.0.1:8080:8080
|
||||||
- 127.0.0.1:${WEBAPP_SERVER_PORT:-8081}:${WEBAPP_SERVER_PORT:-8081}
|
- 127.0.0.1:${WEBAPP_SERVER_PORT:-8081}:${WEBAPP_SERVER_PORT:-8081}
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:8080/healthz >/dev/null || exit 1"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
start_period: 30s
|
||||||
|
|
||||||
remnawave-tg-shop-db:
|
remnawave-tg-shop-db:
|
||||||
image: postgres:17
|
image: postgres:17
|
||||||
|
|||||||
Reference in New Issue
Block a user