mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-22 00:27:44 +01:00
reload config before initialization of controllers
This commit is contained in:
parent
dadb52323b
commit
9d103d3b09
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
7
main.go
7
main.go
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user