feat: add health check endpoints for Bot and Web #63

Closed
Toutsu wants to merge 0 commits from feature/issue-58-health-checks into main
Owner

Summary

Добавлены health check endpoints для обоих сервисов (Bot и Web) и настроены healthcheck секции в Docker Compose.

PR #63 был fast-forward'нут до текущего main после merge PR #79, поэтому версия согласована с актуальной веткой: 2.0.0. Изменения health check уже находятся в main через общий merge-коммит 7cecb72.

Changes

  • Web (GmRelay.Web):

    • Добавлен endpoint /health с проверкой доступности PostgreSQL (readiness probe)
    • Добавлен endpoint /alive для liveness probe
    • /health возвращает 200 OK + JSON при нормальной работе, 503 при недоступности БД
    • Добавлен NpgsqlHealthCheck — lightweight health check с запросом SELECT 1
  • Bot (GmRelay.Bot):

    • Добавлен BotHealthCheckHostedService — lightweight HTTP-сервер на HttpListener, слушающий порт 8081
    • Endpoint /health возвращает 200 OK + JSON при запущенном боте
    • Порт 8081 exposed в Dockerfile
    • Установлен wget в runtime-образ для healthcheck команд
  • compose.yaml:

    • Добавлены healthcheck секции для сервисов bot и web
    • Проверка каждые 10s, timeout 5s, 3 retries
  • Tests:

    • Добавлены TDD-тесты для Web health endpoint (200 и 503 сценарии)
    • Добавлены TDD-тесты для Bot health endpoint (200)
  • Version reconciliation:

Test plan

  • dotnet build — локально на main, 0 warnings / 0 errors
  • dotnet test — локально на main, 145/145 passed
  • dotnet format GM-Relay.slnx --verify-no-changes — локально, clean
  • dotnet restore GM-Relay.slnx --locked-mode — локально, success
  • PR CI на health-check head: Gitea Actions run #179 — success
  • PR CI после fast-forward до main / 2.0.0: Gitea Actions run #183 — success
  • Deploy main после merge PR #79: Gitea Actions run #182 — success

Workflow

  • CI passes on original PR head (#179)
  • CI passes after version reconciliation (#183)
  • Review/merge path handled: diff is empty, own approval is blocked by Gitea, merge API returns 405 because head equals base
  • PR closed as already integrated via PR #79 merge commit 7cecb72
  • Deployed via main (#182)
  • Release published: v2.0.0
  • Issue #58 closed with release reference

Closes #58

## Summary Добавлены health check endpoints для обоих сервисов (Bot и Web) и настроены healthcheck секции в Docker Compose. PR #63 был fast-forward'нут до текущего `main` после merge PR #79, поэтому версия согласована с актуальной веткой: **2.0.0**. Изменения health check уже находятся в `main` через общий merge-коммит `7cecb72`. ## Changes - **Web** (`GmRelay.Web`): - Добавлен endpoint `/health` с проверкой доступности PostgreSQL (readiness probe) - Добавлен endpoint `/alive` для liveness probe - `/health` возвращает `200 OK + JSON` при нормальной работе, `503` при недоступности БД - Добавлен `NpgsqlHealthCheck` — lightweight health check с запросом `SELECT 1` - **Bot** (`GmRelay.Bot`): - Добавлен `BotHealthCheckHostedService` — lightweight HTTP-сервер на `HttpListener`, слушающий порт `8081` - Endpoint `/health` возвращает `200 OK + JSON` при запущенном боте - Порт `8081` exposed в Dockerfile - Установлен `wget` в runtime-образ для healthcheck команд - **compose.yaml**: - Добавлены `healthcheck` секции для сервисов `bot` и `web` - Проверка каждые 10s, timeout 5s, 3 retries - **Tests**: - Добавлены TDD-тесты для Web health endpoint (`200` и `503` сценарии) - Добавлены TDD-тесты для Bot health endpoint (`200`) - **Version reconciliation**: - Первоначальный bump `1.15.1 → 1.16.0` заменён актуальной версией `2.0.0` из PR #79 - Синхронизированы: `Directory.Build.props`, `compose.yaml`, `.gitea/workflows/deploy.yml`, `NavMenu.razor` ## Test plan - [x] `dotnet build` — локально на `main`, 0 warnings / 0 errors - [x] `dotnet test` — локально на `main`, 145/145 passed - [x] `dotnet format GM-Relay.slnx --verify-no-changes` — локально, clean - [x] `dotnet restore GM-Relay.slnx --locked-mode` — локально, success - [x] PR CI на health-check head: Gitea Actions run #179 — success - [x] PR CI после fast-forward до `main` / `2.0.0`: Gitea Actions run #183 — success - [x] Deploy `main` после merge PR #79: Gitea Actions run #182 — success ## Workflow - [x] CI passes on original PR head (#179) - [x] CI passes after version reconciliation (#183) - [x] Review/merge path handled: diff is empty, own approval is blocked by Gitea, merge API returns 405 because head equals base - [x] PR closed as already integrated via PR #79 merge commit `7cecb72` - [x] Deployed via `main` (#182) - [x] Release published: [v2.0.0](https://git.codeanddice.ru/Toutsu/GmRelayBot/releases/tag/v2.0.0) - [x] Issue #58 closed with release reference Closes #58
Toutsu added 1 commit 2026-05-13 10:54:51 +03:00
feat: add health check endpoints for Bot and Web
PR Checks / test-and-build (pull_request) Successful in 8m53s
3bea327043
- Web: add /health endpoint with PostgreSQL readiness check (returns 200+JSON or 503)
- Web: add /alive endpoint for liveness probe
- Bot: add BotHealthCheckHostedService serving /health on port 8081 via HttpListener
- Bot: expose port 8081 in Dockerfile and install wget for healthcheck
- compose.yaml: add healthcheck sections for bot and web services
- tests: add TDD tests for both health endpoints

Bump version -> 1.16.0

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Toutsu added 1 commit 2026-05-13 11:17:19 +03:00
fix: address review feedback for health check endpoints
PR Checks / test-and-build (pull_request) Successful in 8m34s
105b3c59d7
- Install wget in Web Dockerfile for compose healthcheck
- Ensure HttpListener response is always closed in BotHealthCheckHostedService
- Use ephemeral port in Bot health check test to avoid port conflicts
- Rename NpgsqlHealthCheck test to reflect actual behavior

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Author
Owner

Workflow cleanup after version reconciliation:

  • Branch feature/issue-58-health-checks fast-forwarded to current main at 7cecb72.
  • Version reconciled with PR #79: 2.0.0 across Directory.Build.props, compose.yaml, .gitea/workflows/deploy.yml, and NavMenu.razor.
  • PR diff is empty because health check commits are already included in main through the PR #79 merge path.
  • CI after reconciliation: Gitea Actions run #183 — success.
  • Deploy on main: Gitea Actions run #182 — success.

Merge API returns 405 for this already-up-to-date PR, so closing it as integrated rather than creating an empty merge.

Workflow cleanup after version reconciliation: - Branch `feature/issue-58-health-checks` fast-forwarded to current `main` at `7cecb72`. - Version reconciled with PR #79: `2.0.0` across `Directory.Build.props`, `compose.yaml`, `.gitea/workflows/deploy.yml`, and `NavMenu.razor`. - PR diff is empty because health check commits are already included in `main` through the PR #79 merge path. - CI after reconciliation: Gitea Actions run #183 — success. - Deploy on `main`: Gitea Actions run #182 — success. Merge API returns 405 for this already-up-to-date PR, so closing it as integrated rather than creating an empty merge.
Toutsu closed this pull request 2026-05-15 11:56:26 +03:00
Some checks are pending
Deploy Telegram Bot / build-and-push (push) Successful in 7m11s
Deploy Telegram Bot / scan-images (push) Successful in 2m41s
Deploy Telegram Bot / deploy (push) Successful in 17s
PR Checks / test-and-build (pull_request) Successful in 11m17s

Pull request closed

Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Toutsu/GmRelayBot#63