Skip to content

Commit

Permalink
Response for context on retry database connection (#9444)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored Dec 20, 2019
1 parent e2fc0a0 commit 050a8af
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions routers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package routers

import (
"context"
"fmt"
"strings"
"time"

Expand Down Expand Up @@ -57,6 +58,11 @@ func NewServices() {
func initDBEngine(ctx context.Context) (err error) {
log.Info("Beginning ORM engine initialization.")
for i := 0; i < setting.Database.DBConnectRetries; i++ {
select {
case <-ctx.Done():
return fmt.Errorf("Aborted due to shutdown:\nin retry ORM engine initialization")
default:
}
log.Info("ORM engine initialization attempt #%d/%d...", i+1, setting.Database.DBConnectRetries)
if err = models.NewEngine(ctx, migrations.Migrate); err == nil {
break
Expand Down

0 comments on commit 050a8af

Please sign in to comment.