From 1ab09e4f1b27789121dfba9a6c6e4aa0011ab215 Mon Sep 17 00:00:00 2001 From: Peter Smit Date: Thu, 5 Feb 2015 12:12:37 +0200 Subject: Add option to provide configuration file on command line --- modules/setting/setting.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'modules/setting') diff --git a/modules/setting/setting.go b/modules/setting/setting.go index e7c44cdd..79aaf7a0 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -124,6 +124,7 @@ var ( Cfg *ini.File ConfRootPath string CustomPath string // Custom directory path. + CustomConf string ProdMode bool RunUser string IsWindows bool @@ -172,13 +173,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 -- cgit v1.2.3