From dae1a6889bb9e7692d3886f7ebed4f9d05b50e71 Mon Sep 17 00:00:00 2001 From: 3252a8 <3252a8@proton.me> Date: Mon, 27 Apr 2026 08:43:58 +0300 Subject: [PATCH] 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. --- bot/app/web/web_server.py | 5 +++++ docker-compose.yml | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/bot/app/web/web_server.py b/bot/app/web/web_server.py index ca5365f..0c10052 100644 --- a/bot/app/web/web_server.py +++ b/bot/app/web/web_server.py @@ -58,6 +58,11 @@ async def build_and_start_web_app( app = web.Application() _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) telegram_uses_webhook_mode = bool(settings.WEBHOOK_BASE_URL) diff --git a/docker-compose.yml b/docker-compose.yml index 55cc2f2..4539c56 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,12 @@ services: ports: - 127.0.0.1:8080:8080 - 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: image: postgres:17