1
0
Fork 0
forked from forgejo/forgejo

Merge pull request #905 from phsmit/conf_on_cli

Add option to provide configuration file on command line
This commit is contained in:
无闻 2015-02-08 20:22:02 -05:00
commit cd0ee35b3f
8 changed files with 37 additions and 13 deletions

View file

@ -125,6 +125,7 @@ var (
Cfg *ini.File
ConfRootPath string
CustomPath string // Custom directory path.
CustomConf string
ProdMode bool
RunUser string
IsWindows bool
@ -173,13 +174,16 @@ func NewConfigContext() {
CustomPath = path.Join(workDir, "custom")
}
cfgPath := path.Join(CustomPath, "conf/app.ini")
if com.IsFile(cfgPath) {
if err = Cfg.Append(cfgPath); err != nil {
log.Fatal(4, "Fail to load custom 'conf/app.ini': %v", err)
if len(CustomConf) == 0 {
CustomConf = path.Join(CustomPath, "conf/app.ini")
}
if com.IsFile(CustomConf) {
if err = Cfg.Append(CustomConf); err != nil {
log.Fatal(4, "Fail to load custom conf '%s': %v", CustomConf, err)
}
} else {
log.Warn("No custom 'conf/app.ini' found, ignore this if you're running first time")
log.Warn("Custom config (%s) not found, ignore this if you're running first time", CustomConf)
}
Cfg.NameMapper = ini.AllCapsUnderscore