From d4e8ae329c8f5b8105d2631a39af0f9b8f792e09 Mon Sep 17 00:00:00 2001 From: Juraj Bubniak Date: Mon, 30 Dec 2019 08:59:14 +0100 Subject: [PATCH] Check store on startup. --- cmd/server.go | 8 ++++++++ 1 file changed, 8 insertions(+) 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)