Files
mc-router/internal/automc/wire.go
T
claude-timemachine e2ce0453fa
CI / validate (push) Successful in 12s
CI / docker (push) Successful in 15s
automc: operator UI on AUTOMC_UI_BINDING
Adds a separate HTTP server (not the upstream API on :25590) for the
operator dashboard. Single-page UI with two panes:
  * routes table — current pg-synced mappings, polled every 2s
  * logs — SSE stream backed by a logrus hook + 500-entry ring buffer

Opt-in via AUTOMC_UI_BINDING (e.g. ":8082"); unset = no-op, behaves
exactly like upstream. Designed to live behind server-manager's
/infra/mc-router/* reverse-proxy.

Patch is internal/automc-only, same fork philosophy as the rest —
upstream files stay verbatim.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-10 18:03:48 +02:00

34 lines
972 B
Go

// Package automc wires automc-specific extensions onto upstream mc-router.
//
// All behavior is opt-in via env vars; when AUTOMC_DSN is unset, Wire is a no-op
// and the binary behaves exactly like upstream itzg/mc-router.
package automc
import (
"context"
"os"
"github.com/sirupsen/logrus"
)
func Wire(ctx context.Context) error {
dsn := os.Getenv("AUTOMC_DSN")
if dsn == "" {
return nil
}
waker := newWakerConfig(os.Getenv("AUTOMC_WAKER_URL"), os.Getenv("AUTOMC_WAKER_TOKEN"))
s := newSyncer(dsn, waker)
go s.run(ctx)
logrus.Info("automc: pg route sync started")
// Operator UI on a separate port — upstream's API_BINDING stays
// JSON-only and untouched. Enable by setting AUTOMC_UI_BINDING (e.g.
// ":8082"); leave unset to skip and behave exactly like upstream.
if uiBinding := os.Getenv("AUTOMC_UI_BINDING"); uiBinding != "" {
bus := NewLogBus(500)
logrus.AddHook(&logrusBusHook{bus: bus})
startUI(ctx, uiBinding, bus)
}
return nil
}