aboutsummaryrefslogtreecommitdiffstats
path: root/routers/init.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-12-15 09:51:28 +0000
committerGitHub <noreply@github.com>2019-12-15 09:51:28 +0000
commite3c3b33ea7a5a223e22688c3f0eb2d3dab9f991c (patch)
tree21dcdc6ec138a502590550672ac0a11f364935ea /routers/init.go
parent8bea92c3dc162e24f6dcc2902dfed5ab94576826 (diff)
downloadgitea-e3c3b33ea7a5a223e22688c3f0eb2d3dab9f991c.tar.gz
gitea-e3c3b33ea7a5a223e22688c3f0eb2d3dab9f991c.zip
Graceful: Xorm, RepoIndexer, Cron and Others (#9282)
* Change graceful to use a singleton obtained through GetManager instead of a global. * Graceful: Make TestPullRequests shutdownable * Graceful: Make the cron tasks graceful * Graceful: AddTestPullRequest run in graceful ctx * Graceful: SyncMirrors shutdown * Graceful: SetDefaultContext for Xorm to be HammerContext * Avoid starting graceful for migrate commands and checkout * Graceful: DeliverHooks now can be shutdown * Fix multiple syncing errors in modules/sync/UniqueQueue & Make UniqueQueue closable * Begin the process of making the repo indexer shutdown gracefully
Diffstat (limited to 'routers/init.go')
-rw-r--r--routers/init.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/routers/init.go b/routers/init.go
index 81418a4ad5..01df15d6c5 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -5,6 +5,7 @@
package routers
import (
+ "context"
"strings"
"time"
@@ -53,11 +54,11 @@ func NewServices() {
}
// In case of problems connecting to DB, retry connection. Eg, PGSQL in Docker Container on Synology
-func initDBEngine() (err error) {
+func initDBEngine(ctx context.Context) (err error) {
log.Info("Beginning ORM engine initialization.")
for i := 0; i < setting.Database.DBConnectRetries; i++ {
log.Info("ORM engine initialization attempt #%d/%d...", i+1, setting.Database.DBConnectRetries)
- if err = models.NewEngine(migrations.Migrate); err == nil {
+ if err = models.NewEngine(ctx, migrations.Migrate); err == nil {
break
} else if i == setting.Database.DBConnectRetries-1 {
return err
@@ -71,9 +72,9 @@ func initDBEngine() (err error) {
}
// GlobalInit is for global configuration reload-able.
-func GlobalInit() {
+func GlobalInit(ctx context.Context) {
setting.NewContext()
- if err := git.Init(); err != nil {
+ if err := git.Init(ctx); err != nil {
log.Fatal("Git module init failed: %v", err)
}
setting.CheckLFSVersion()
@@ -88,7 +89,7 @@ func GlobalInit() {
highlight.NewContext()
external.RegisterParsers()
markup.Init()
- if err := initDBEngine(); err == nil {
+ if err := initDBEngine(ctx); err == nil {
log.Info("ORM engine initialization successful!")
} else {
log.Fatal("ORM engine initialization failed: %v", err)