Skip to content

Commit

Permalink
Do not exit if pgpool is unreachable on startup
Browse files Browse the repository at this point in the history
If pgpool is down on exporter startup, keep waiting for pgpool to be up
  • Loading branch information
AnirudhGoel authored Mar 10, 2023
1 parent e76f5f6 commit 979dfb6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pgpool2_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,13 @@ func NewExporter(dsn string, namespace string) *Exporter {

db, err := getDBConn(dsn)

if err != nil {
// If pgpool is down on exporter startup, keep waiting for pgpool to be up
for err != nil {
level.Error(Logger).Log("err", err)
os.Exit(1)
level.Info(Logger).Log("info", "Sleeping for 5 seconds before trying to connect again")
time.Sleep(5 * time.Second)

db, err = getDBConn(dsn)
}

return &Exporter{
Expand Down

0 comments on commit 979dfb6

Please sign in to comment.