diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-02-22 09:05:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-22 09:05:26 +0800 |
commit | 648d9e253c1924b832248f26fee42b2fb64dc3bc (patch) | |
tree | 51649fad974cd7284a47d30e412c90e7ab72cd2c /internal/db/models.go | |
parent | 5b14cc6f0b7b661beb2640a94bd15660cdb48587 (diff) |
conf: overhaul server settings (#5928)
* conf: rename package
* Requires Go 1.12
* Fix lint
* Fix lint
* Overhaul
* db: fix tests
* Save my work
* Fix tests
* Server.UnixSocketPermission
* Server.LocalRootURL
* SSH settings
* Server.OfflineMode
* Save my work
* App.Version
* Remove [server] STATIC_ROOT_PATH
* Server.LandingURL
Diffstat (limited to 'internal/db/models.go')
-rw-r--r-- | internal/db/models.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/internal/db/models.go b/internal/db/models.go index 403c04ff..9d4f2209 100644 --- a/internal/db/models.go +++ b/internal/db/models.go @@ -24,8 +24,8 @@ import ( "xorm.io/core" "xorm.io/xorm" + "gogs.io/gogs/internal/conf" "gogs.io/gogs/internal/db/migrations" - "gogs.io/gogs/internal/setting" ) // Engine represents a XORM engine or session. @@ -75,17 +75,17 @@ func init() { } func LoadConfigs() { - sec := setting.Cfg.Section("database") + sec := conf.File.Section("database") DbCfg.Type = sec.Key("DB_TYPE").String() switch DbCfg.Type { case "sqlite3": - setting.UseSQLite3 = true + conf.UseSQLite3 = true case "mysql": - setting.UseMySQL = true + conf.UseMySQL = true case "postgres": - setting.UsePostgreSQL = true + conf.UsePostgreSQL = true case "mssql": - setting.UseMSSQL = true + conf.UseMSSQL = true } DbCfg.Host = sec.Key("HOST").String() DbCfg.Name = sec.Key("NAME").String() @@ -189,8 +189,8 @@ func SetEngine() (err error) { // WARNING: for serv command, MUST remove the output to os.stdout, // so use log file to instead print to stdout. - sec := setting.Cfg.Section("log.xorm") - logger, err := log.NewFileWriter(path.Join(setting.LogRootPath, "xorm.log"), + sec := conf.File.Section("log.xorm") + logger, err := log.NewFileWriter(path.Join(conf.LogRootPath, "xorm.log"), log.FileRotationConfig{ Rotate: sec.Key("ROTATE").MustBool(true), Daily: sec.Key("ROTATE_DAILY").MustBool(true), @@ -206,7 +206,7 @@ func SetEngine() (err error) { x.SetMaxIdleConns(0) x.SetConnMaxLifetime(time.Second) - if setting.ProdMode { + if conf.IsProdMode() { x.SetLogger(xorm.NewSimpleLogger3(logger, xorm.DEFAULT_LOG_PREFIX, xorm.DEFAULT_LOG_FLAG, core.LOG_WARNING)) } else { x.SetLogger(xorm.NewSimpleLogger(logger)) @@ -389,7 +389,7 @@ func ImportDatabase(dirPath string, verbose bool) (err error) { } // PostgreSQL needs manually reset table sequence for auto increment keys - if setting.UsePostgreSQL { + if conf.UsePostgreSQL { rawTableName := snakeMapper.Obj2Table(tableName) seqName := rawTableName + "_id_seq" if _, err = x.Exec(fmt.Sprintf(`SELECT setval('%s', COALESCE((SELECT MAX(id)+1 FROM "%s"), 1), false);`, seqName, rawTableName)); err != nil { |