diff --git a/cmd/server.go b/cmd/server.go index 07f57b5..a9b520c 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -1,6 +1,7 @@ package cmd import ( + "context" "fmt" "github.com/jbub/pgbouncer_exporter/internal/collector" @@ -28,6 +29,13 @@ func runServer(ctx *cli.Context) error { } defer st.Close() + checkCtx, cancel := context.WithTimeout(context.Background(), cfg.StoreTimeout) + defer cancel() + + if err := st.Check(checkCtx); err != nil { + return fmt.Errorf("could not check store: %v", err) + } + exp := collector.New(cfg, st) srv := server.New(cfg, exp)