diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-12-20 13:39:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-20 13:39:33 +0800 |
commit | 050a8af4243d7f5fff0a2f492b9166f4dfdf0ecf (patch) | |
tree | 8ba9a348e3295cb8d13df3d7d7f32bad3cc8d323 /routers/init.go | |
parent | e2fc0a0dfd99a86279eeece846cd911fe0c5ac6c (diff) | |
download | gitea-050a8af4243d7f5fff0a2f492b9166f4dfdf0ecf.tar.gz gitea-050a8af4243d7f5fff0a2f492b9166f4dfdf0ecf.zip |
Response for context on retry database connection (#9444)
Diffstat (limited to 'routers/init.go')
-rw-r--r-- | routers/init.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/routers/init.go b/routers/init.go index 01df15d6c5..ee74ef7970 100644 --- a/routers/init.go +++ b/routers/init.go @@ -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 |