-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Labels
type/refactoringExisting code has been cleaned up. There should be no new functionality.Existing code has been cleaned up. There should be no new functionality.
Description
Lines 19 to 39 in 1bfb0a2
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 | |
} else if i == setting.Database.DBConnectRetries-1 { | |
return err | |
} | |
log.Error("ORM engine initialization attempt #%d/%d failed. Error: %v", i+1, setting.Database.DBConnectRetries, err) | |
log.Info("Backing off for %d seconds", int64(setting.Database.DBConnectBackoff/time.Second)) | |
time.Sleep(setting.Database.DBConnectBackoff) | |
} | |
models.HasEngine = true | |
return nil | |
} |
"...I think this might be better in modules/database.
If you think about what else is in here they're all handlers/middleware of some sort - this is very definitely not and therefore should not be here. ..."
Originally posted by @zeripath in #15800 (comment)
Metadata
Metadata
Assignees
Labels
type/refactoringExisting code has been cleaned up. There should be no new functionality.Existing code has been cleaned up. There should be no new functionality.