From f83db078f0603c775cd1b1bb016f996b65a04835 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 24 Aug 2019 17:24:45 +0800 Subject: Move database settings from models to setting (#7806) * move database settings from models to setting * update docs * fix checkout pr * fix tests * fix lint * remove unsupported tidb options * correct wrong variable name * remove tidb totally --- routers/init.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'routers/init.go') diff --git a/routers/init.go b/routers/init.go index 4724da8627..fdf90904ce 100644 --- a/routers/init.go +++ b/routers/init.go @@ -47,16 +47,16 @@ func NewServices() { // In case of problems connecting to DB, retry connection. Eg, PGSQL in Docker Container on Synology func initDBEngine() (err error) { log.Info("Beginning ORM engine initialization.") - for i := 0; i < setting.DBConnectRetries; i++ { - log.Info("ORM engine initialization attempt #%d/%d...", i+1, setting.DBConnectRetries) + 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 { break - } else if i == setting.DBConnectRetries-1 { + } else if i == setting.Database.DBConnectRetries-1 { return err } - log.Error("ORM engine initialization attempt #%d/%d failed. Error: %v", i+1, setting.DBConnectRetries, err) - log.Info("Backing off for %d seconds", int64(setting.DBConnectBackoff/time.Second)) - time.Sleep(setting.DBConnectBackoff) + 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 @@ -73,7 +73,7 @@ func GlobalInit() { log.Trace("AppWorkPath: %s", setting.AppWorkPath) log.Trace("Custom path: %s", setting.CustomPath) log.Trace("Log path: %s", setting.LogRootPath) - models.LoadConfigs() + NewServices() if setting.InstallLock { @@ -102,12 +102,9 @@ func GlobalInit() { models.InitDeliverHooks() models.InitTestPullRequests() } - if models.EnableSQLite3 { + if setting.EnableSQLite3 { log.Info("SQLite3 Supported") } - if models.EnableTiDB { - log.Info("TiDB Supported") - } checkRunMode() if setting.InstallLock && setting.SSH.StartBuiltinServer { -- cgit v1.2.3