#9 修改读取配置文件的路径

Merged
weichenglei merged 1 commits from fix_start into develop 3 years ago
  1. +2
    -3
      infra/config/config.go
  2. +6
    -1
      infra/logger/config.go

+ 2
- 3
infra/config/config.go View File

@ -3,7 +3,6 @@ package config
import (
"LAPP_ETL/utils"
"github.com/spf13/viper"
"path"
)
var AppConfig Config
@ -48,13 +47,13 @@ type ETCD struct {
}
func InitConfig() (err error) {
baseDir, err := utils.GetCurrentPath("/conf")
baseDir, err := utils.GetCurrentPath("conf")
if err != nil {
return
}
viper.SetConfigName("app_config")
viper.SetConfigType("yaml")
viper.AddConfigPath(path.Join(baseDir, "../conf/"))
viper.AddConfigPath(baseDir)
if err = viper.ReadInConfig(); err != nil {
return
}


+ 6
- 1
infra/logger/config.go View File

@ -1,6 +1,7 @@
package logger
import (
"LAPP_ETL/utils"
"errors"
"github.com/spf13/viper"
)
@ -48,9 +49,13 @@ type outputSettings struct {
func InitConfig() error {
var err error
baseDir, err := utils.GetCurrentPath("conf")
if err != nil {
return err
}
viper.SetConfigName("log_config")
viper.SetConfigType("yaml")
viper.AddConfigPath("./conf/")
viper.AddConfigPath(baseDir)
if err = viper.ReadInConfig(); err != nil {
return err
}


Loading…
Cancel
Save