Phase 8: widgets and polish

- Live job card widget (progress bar, in-widget cancel via widget_query)
  and live invoice widget (QR drawn from a bitmap, countdown, paid state),
  Bot API 10.4 sendWidget, private chats only
- Automatic fallback to the ordinary message when sendWidget fails, with
  a breaker that pauses widgets after repeated failures or on servers
  without the method; TELEGRAM_WIDGETS
- Prometheus metrics on the core (/metrics) and on every worker: queue
  depth and wait, slots, heartbeats, job outcomes, errors per site,
  deliveries, cache, invoices, Lightning, ledger check, widgets
- Example Prometheus config and alert rules, Caddyfile, dashboard notes
- Load test: cmd/loadtest and deploy/loadtest (make loadtest)
- Browser check of the widgets' HTML, including decoding a drawn QR
- docs/DEPLOY.md (production in under an hour) and docs/MONITORING.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michilis
2026-11-18 18:24:36 +00:00
co-authored by Claude Opus 5.5
parent f1f9c6156c
commit 3c153af97f
45 changed files with 3158 additions and 20 deletions
+20 -2
View File
@@ -1,7 +1,8 @@
# Operations
How to deploy, scale and look after the bot. For workers see
[WORKERS.md](WORKERS.md).
How to deploy, scale and look after the bot. For a first production
setup, follow [DEPLOY.md](DEPLOY.md) from top to bottom. For workers see
[WORKERS.md](WORKERS.md), for metrics and alerts [MONITORING.md](MONITORING.md).
## Deploy with docker compose
@@ -133,6 +134,7 @@ Routes the proxy must pass through:
| `/app/...` | The Mini App and its API, opened by Telegram clients |
| `/worker/v1/...` | Remote workers. Allow long requests (30 s) and large uploads. |
| `/healthz` | Your monitoring |
| `/metrics` | Prometheus, over the private network only. `deploy/caddy/Caddyfile` blocks it |
Without `PUBLIC_URL` the bot still works: long polling for Telegram,
polling for payments, workers on the same network.
@@ -188,6 +190,22 @@ sent again when they change, because Telegram rate limits those calls.
- `I18N_PSEUDO=true` adds a test language for owners, see
[TRANSLATING.md](TRANSLATING.md).
## Live widgets
In private chats the download status and invoices are HTML widgets (Bot
API 10.4): a progress bar with its own Cancel button, and an invoice with
its QR code, a countdown and the paid state. Nothing needs setting up.
- Telegram shows widgets in private chats only, so groups keep ordinary
messages.
- If `sendWidget` fails, that message is sent the ordinary way. If it
fails three times in a row, or the Bot API server does not know the
method (an older local Bot API server), the bot stops trying for ten
minutes or an hour, then tries again. `dlbot_widgets_total` counts both.
- Apps too old for widgets show the caption: the title of the download,
or the invoice text with the copyable invoice and its buttons.
- `TELEGRAM_WIDGETS=false` turns them off.
## Health and logs
- `GET /healthz` on the core answers 200 while the database is reachable.