conf.go 500 Bytes
Newer Older
kzkzzzz's avatar
kzkzzzz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
package conf

import (
	"flag"
	"grpc-base/common/conf"
	"grpc-base/common/logger"
	"grpc-base/common/mysql"
	"grpc-base/common/server"
)

func init() {
	// 读取命令, 配置文件参数, 不指定则当前路径server.yaml
	flag.StringVar(&ConfPath, "conf", "server.yaml", "配置文件路径")
}

var (
	ConfPath string
	Conf     = &Config{}
)

type Config struct {
	Server *server.Config
	Log    *logger.Config
	Mysql  *mysql.Config
}

func LoadConfig() {
	conf.LoadFromYaml(ConfPath, &Conf)
}