summaryrefslogtreecommitdiff
path: root/internal/daemon/daemon.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-16 10:22:48 +0300
committerPaul Buetow <paul@buetow.org>2026-04-16 10:22:48 +0300
commit4371aa94b0793c70a3e146fad6398f0dcb540048 (patch)
treec7a4e1fd6726927d3344dace8d38cda7efef706d /internal/daemon/daemon.go
parentee8221e6c88640dba31c69c59c19e65a8dc54a3e (diff)
Release 0.5.1: auto-unexclude, merge excluded_host into auth DB0.5.1
- /metrics: auto-remove exclusion when records mtime > excluded_at so hosts that resume uploading unexclude themselves on next scrape - Consolidate excluded_host table into the auth DB (goprecords-auth.db) instead of a separate file — removes -db daemon flag and GOPRECORDS_DB env - README: add host exclusion section with kubectl exec examples Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/daemon/daemon.go')
-rw-r--r--internal/daemon/daemon.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/internal/daemon/daemon.go b/internal/daemon/daemon.go
index 326224e..6346df6 100644
--- a/internal/daemon/daemon.go
+++ b/internal/daemon/daemon.go
@@ -31,7 +31,6 @@ type Config struct {
StatsDir string
Addr string
AuthDB string
- DB string
LogOutput io.Writer
}
@@ -42,17 +41,17 @@ func NewHandler(statsDir string) (http.Handler, error) {
if err != nil {
return nil, fmt.Errorf("auth db: %w", err)
}
- return routes(statsDir, "", "", store), nil
+ return routes(statsDir, authkeys.DefaultPath(statsDir), store), nil
}
-func routes(statsDir, authDB, db string, store *authkeys.Store) http.Handler {
+func routes(statsDir, authDB string, store *authkeys.Store) http.Handler {
mux := http.NewServeMux()
mux.HandleFunc("/", root(statsDir))
mux.HandleFunc("/health", health)
mux.HandleFunc("/livez", health)
mux.HandleFunc("/readyz", readiness(statsDir, authDB))
mux.HandleFunc("/report", report(statsDir))
- mux.HandleFunc("/metrics", metricsHandler(statsDir, db))
+ mux.HandleFunc("/metrics", metricsHandler(statsDir, authDB))
mux.Handle("/upload/", uploadHandler(statsDir, store))
return mux
}
@@ -148,12 +147,16 @@ func Run(ctx context.Context, cfg Config) error {
}
w := logWriter(cfg)
slogLog, textHandler := newDaemonLogger(w)
+ resolvedAuthDB := cfg.AuthDB
+ if resolvedAuthDB == "" {
+ resolvedAuthDB = authkeys.DefaultPath(cfg.StatsDir)
+ }
store, err := openAuthStore(ctx, cfg.StatsDir, cfg.AuthDB)
if err != nil {
return fmt.Errorf("auth db: %w", err)
}
defer store.Close()
- srv := newDaemonHTTPServer(cfg.Addr, withAccessLog(slogLog, routes(cfg.StatsDir, cfg.AuthDB, cfg.DB, store)),
+ srv := newDaemonHTTPServer(cfg.Addr, withAccessLog(slogLog, routes(cfg.StatsDir, resolvedAuthDB, store)),
slog.NewLogLogger(textHandler, slog.LevelError))
slogLog.Info("daemon_listen", "addr", cfg.Addr)
errCh := make(chan error, 1)