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
+8 -4
View File
@@ -19,6 +19,7 @@ import (
"github.com/noderunners/dlbot/internal/app"
"github.com/noderunners/dlbot/internal/config"
"github.com/noderunners/dlbot/internal/ffmpeg"
"github.com/noderunners/dlbot/internal/metrics"
"github.com/noderunners/dlbot/internal/worker"
"github.com/noderunners/dlbot/internal/workerproto"
"github.com/noderunners/dlbot/internal/ytdlp"
@@ -67,7 +68,7 @@ func main() {
var wg sync.WaitGroup
if cfg.HealthListen != "" {
srv := healthServer(cfg.HealthListen, w)
srv := healthServer(cfg.HealthListen, w, up.get)
wg.Add(1)
go func() {
defer wg.Done()
@@ -104,10 +105,13 @@ func main() {
log.Info("worker stopped")
}
// healthServer answers /healthz. The worker is healthy while the core
// keeps answering its claims and accepts its token.
func healthServer(addr string, w *worker.Worker) *http.Server {
// healthServer answers /healthz and /metrics. The worker is healthy while
// the core keeps answering its claims and accepts its token.
func healthServer(addr string, w *worker.Worker, ytdlpVersion func() string) *http.Server {
mux := http.NewServeMux()
mux.Handle("GET /metrics", metrics.WorkerHandler(metrics.WorkerSource{
Active: w.Active, Capacity: w.Capacity, LastContact: w.LastContact, Outcomes: w.Outcomes, YtDlp: ytdlpVersion,
}))
mux.HandleFunc("GET /healthz", func(rw http.ResponseWriter, _ *http.Request) {
last, authFailed := w.LastContact()
age := time.Since(last)