fix: init config failed
This commit is contained in:
parent
70b73b2974
commit
73295cfabd
1 changed files with 14 additions and 30 deletions
40
cmd/root.go
40
cmd/root.go
|
|
@ -105,42 +105,26 @@ func Execute() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boot 设定配置 (这个逻辑有 BUG )
|
// Boot 设定配置
|
||||||
func Boot() {
|
func Boot() {
|
||||||
|
root := config.Conf.Root
|
||||||
if envFile == "" && appPath != "" {
|
if appPath != "" {
|
||||||
root, err := filepath.Abs(appPath)
|
r, err := filepath.Abs(appPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exception.New("Root error %s", 500, err.Error()).Throw()
|
exception.New("Root error %s", 500, err.Error()).Throw()
|
||||||
}
|
}
|
||||||
|
root = r
|
||||||
|
}
|
||||||
|
if envFile != "" {
|
||||||
|
config.Conf = config.LoadFrom(envFile)
|
||||||
|
} else {
|
||||||
config.Conf = config.LoadFrom(filepath.Join(root, ".env"))
|
config.Conf = config.LoadFrom(filepath.Join(root, ".env"))
|
||||||
config.Conf.Root = root
|
}
|
||||||
|
|
||||||
if config.Conf.Mode == "production" {
|
if config.Conf.Mode == "production" {
|
||||||
config.Production()
|
config.Production()
|
||||||
} else if config.Conf.Mode == "development" {
|
} else if config.Conf.Mode == "development" {
|
||||||
config.Development()
|
config.Development()
|
||||||
}
|
}
|
||||||
|
fmt.Println(root)
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if envFile != "" && appPath == "" { // 指定环境变量文件
|
|
||||||
// config.SetEnvFile(envFile)
|
|
||||||
config.Conf = config.LoadFrom(envFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
if envFile != "" && appPath != "" {
|
|
||||||
root, err := filepath.Abs(appPath)
|
|
||||||
if err != nil {
|
|
||||||
exception.New("Root error %s", 500, err.Error()).Throw()
|
|
||||||
}
|
|
||||||
config.Conf = config.LoadFrom(envFile)
|
|
||||||
config.Conf.Root = root
|
|
||||||
if config.Conf.Mode == "production" {
|
|
||||||
config.Production()
|
|
||||||
} else if config.Conf.Mode == "development" {
|
|
||||||
config.Development()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue