Skip to content

Commit

Permalink
Fix postgres connection error message displayed even with successful …
Browse files Browse the repository at this point in the history
…connection
  • Loading branch information
louisroyer committed Nov 15, 2024
1 parent 6c9704c commit 1750975
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/tasks/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,13 @@ func (db *DBTask) RunInit(ctx context.Context) error {
defer cancel()
if err := postgres.Ping(); err == nil {
ok = true
logrus.WithFields(logrus.Fields{"attempt": errcnt}).Info("Connected to postgres database.")
cancel()
} else if errcnt < maxAttempts-1 {
logrus.WithFields(logrus.Fields{"attempt": errcnt}).Warn("Could not connect to postgres database. Another attempt is scheduled.")
} else {
logrus.WithFields(logrus.Fields{"attempt": errcnt}).Warn("Could not connect to postgres database.")
}
logrus.WithFields(logrus.Fields{"attempt": errcnt}).Warn("Could not connect to postgres database. Retrying.")
// blocks until success, timeout, or ctx.Done()
select {
case <-wait.Done():
Expand Down

0 comments on commit 1750975

Please sign in to comment.