feat!: let checkers and status page servers reach data only through the api

Only cmd/api connects to Postgres and Redis. Agents authenticate with
tokens created by 'api agent create' and use /agent/v1: checkers long
poll for jobs, which doubles as heartbeat, and report results in
batches. Organizations manage monitors through /api/v1/org/monitors.

BREAKING CHANGE: cmd/checker and cmd/statuspage no longer read
UPTIME_DATABASE_URL or UPTIME_REDIS_*; they need UPTIME_API_URL and
UPTIME_AGENT_TOKEN. UPTIME_CHECKER_REGION is replaced by the region bound
to the agent token.

Closes #10
Closes #11
Closes #12
Closes #13
Closes #49

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 01:12:53 +01:00
1 parent 56862dce84
commit d9891bb050
23 files changed
+1361 -45

No files matched your search

+12 -6
View File
@@ -38,11 +38,16 @@ func run(log *slog.Logger, level *slog.LevelVar, args []string) error {
ctx, stop := platform.SignalContext()
defer stop()
if len(args) > 0 && args[0] == "migrate" {
return migrate(ctx, log, cfg.DatabaseURL, args[1:])
}
if len(args) > 0 && args[0] != "serve" {
return errors.New("usage: api [serve | migrate up|down|status]")
if len(args) > 0 {
switch args[0] {
case "migrate":
return migrate(ctx, log, cfg.DatabaseURL, args[1:])
case "agent", "region":
return admin(ctx, cfg, args)
case "serve":
default:
return errors.New(usage)
}
}
if err := cfg.Validate(); err != nil {
@@ -52,7 +57,7 @@ func run(log *slog.Logger, level *slog.LevelVar, args []string) error {
if err != nil {
return err
}
deps, err := platform.Connect(ctx, cfg.Common, log)
deps, err := platform.Connect(ctx, cfg.Storage, log)
if err != nil {
return err
}
@@ -68,6 +73,7 @@ func run(log *slog.Logger, level *slog.LevelVar, args []string) error {
health.Register(r)
r.StaticFS("/static", web.Static())
srv.Mount(r)
go srv.RunScheduler(ctx)
return platform.Serve(ctx, log, platform.NewHTTPServer(cfg.Listen, r), health, 5*time.Second, cfg.ShutdownTimeout)
}