Skip to content

Commit 050a8af

Browse files
authored
Response for context on retry database connection (#9444)
1 parent e2fc0a0 commit 050a8af

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

routers/init.go

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package routers
66

77
import (
88
"context"
9+
"fmt"
910
"strings"
1011
"time"
1112

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

0 commit comments

Comments
 (0)