reload config before initialization of controllers

This commit is contained in:
Tan Jiang 2016-02-23 12:16:36 +08:00
parent dadb52323b
commit 9d103d3b09
2 changed files with 11 additions and 8 deletions

View File

@ -15,6 +15,7 @@
package controllers
import (
"log"
"os"
"strings"
@ -114,6 +115,16 @@ var langTypes []*langType
func init() {
//conf/app.conf -> os.Getenv("config_path")
configPath := os.Getenv("CONFIG_PATH")
if len(configPath) != 0 {
log.Printf("Config path: %s", configPath)
beego.AppConfigPath = configPath
if err := beego.ParseConfig(); err != nil {
beego.Warning("Failed to parse config file: ", configPath, "error: ", err)
}
}
beego.AddFuncMap("i18n", i18n.Tr)
langs := strings.Split(beego.AppConfig.String("lang::types"), "|")
@ -134,7 +145,6 @@ func init() {
for _, lang := range langs {
if err := i18n.SetMessage(lang, "static/i18n/"+"locale_"+lang+".ini"); err != nil {
beego.Error("Fail to set message file:" + err.Error())
return
}
}
}

View File

@ -68,13 +68,6 @@ func main() {
beego.BConfig.WebConfig.Session.SessionOn = true
//conf/app.conf -> os.Getenv("config_path")
configPath := os.Getenv("CONFIG_PATH")
if len(configPath) != 0 {
beego.Debug(fmt.Sprintf("Config path: %s", configPath))
beego.AppConfigPath = configPath
}
updateInitPassword(ADMIN_USER_ID, os.Getenv("HARBOR_ADMIN_PASSWORD"))
beego.Run()