diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/setting/setting.go | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 85fcbac2b1..692fb9820a 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -391,12 +391,12 @@ func getAppPath() (string, error) { } func getWorkPath(appPath string) string { - workPath := "" - giteaWorkPath := os.Getenv("GITEA_WORK_DIR") + workPath := AppWorkPath - if len(giteaWorkPath) > 0 { + if giteaWorkPath, ok := os.LookupEnv("GITEA_WORK_DIR"); ok { workPath = giteaWorkPath - } else { + } + if len(workPath) == 0 { i := strings.LastIndex(appPath, "/") if i == -1 { workPath = appPath @@ -475,27 +475,40 @@ func CheckLFSVersion() { } } -// NewContext initializes configuration context. -// NOTE: do not print any log except error. -func NewContext() { - Cfg = ini.Empty() - - CustomPath = os.Getenv("GITEA_CUSTOM") +// SetCustomPathAndConf will set CustomPath and CustomConf with reference to the +// GITEA_CUSTOM environment variable and with provided overrides before stepping +// back to the default +func SetCustomPathAndConf(providedCustom, providedConf string) { + if giteaCustom, ok := os.LookupEnv("GITEA_CUSTOM"); ok { + CustomPath = giteaCustom + } + if len(providedCustom) != 0 { + CustomPath = providedCustom + } if len(CustomPath) == 0 { CustomPath = path.Join(AppWorkPath, "custom") } else if !filepath.IsAbs(CustomPath) { CustomPath = path.Join(AppWorkPath, CustomPath) } - if len(CustomPID) > 0 { - createPIDFile(CustomPID) + if len(providedConf) != 0 { + CustomConf = providedConf } - if len(CustomConf) == 0 { CustomConf = path.Join(CustomPath, "conf/app.ini") } else if !filepath.IsAbs(CustomConf) { CustomConf = path.Join(CustomPath, CustomConf) } +} + +// NewContext initializes configuration context. +// NOTE: do not print any log except error. +func NewContext() { + Cfg = ini.Empty() + + if len(CustomPID) > 0 { + createPIDFile(CustomPID) + } if com.IsFile(CustomConf) { if err := Cfg.Append(CustomConf); err != nil { |