Browse Source

Response for context on retry database connection (#9444)

for-closed-social
Lunny Xiao 4 years ago
committed by GitHub
parent
commit
050a8af424
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      routers/init.go

+ 6
- 0
routers/init.go View File

@ -6,6 +6,7 @@ package routers
import (
"context"
"fmt"
"strings"
"time"
@ -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

Loading…
Cancel
Save