summaryrefslogtreecommitdiff
path: root/internal/daemon/daemon.go
diff options
context:
space:
mode:
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)