Browse Source

Merge pull request '修改读取配置文件的路径' (#9) from fix_start into develop

Reviewed-on: http://101.201.121.115:3000/leo/LAPP_ETL/pulls/9
feature_trigger
weichenglei 3 years ago
parent
commit
4e71310a44
2 changed files with 8 additions and 4 deletions
  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 ( import (
"LAPP_ETL/utils" "LAPP_ETL/utils"
"github.com/spf13/viper" "github.com/spf13/viper"
"path"
) )
var AppConfig Config var AppConfig Config
@ -48,13 +47,13 @@ type ETCD struct {
} }
func InitConfig() (err error) { func InitConfig() (err error) {
baseDir, err := utils.GetCurrentPath("/conf")
baseDir, err := utils.GetCurrentPath("conf")
if err != nil { if err != nil {
return return
} }
viper.SetConfigName("app_config") viper.SetConfigName("app_config")
viper.SetConfigType("yaml") viper.SetConfigType("yaml")
viper.AddConfigPath(path.Join(baseDir, "../conf/"))
viper.AddConfigPath(baseDir)
if err = viper.ReadInConfig(); err != nil { if err = viper.ReadInConfig(); err != nil {
return return
} }


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

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


Loading…
Cancel
Save