Skip to content

Commit

Permalink
Check store on startup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Juraj Bubniak committed Dec 30, 2019
1 parent 777e244 commit d4e8ae3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"context"
"fmt"

"github.com/jbub/pgbouncer_exporter/internal/collector"
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit d4e8ae3

Please sign in to comment.