From 1095c312c7cb3c49534f3bdf43daadc42f0f749a Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 07 十一月 2024 17:07:36 +0800
Subject: [PATCH] fix build
---
config/config.go | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/config/config.go b/config/config.go
index 330859d..b71dc57 100644
--- a/config/config.go
+++ b/config/config.go
@@ -8,18 +8,19 @@
"github.com/spf13/viper"
)
-type database struct {
+type mainConfig struct {
+ ServePort int `mapstructure:"servePort"`
+ WorkerNum int `mapstructure:"workerNum"`
MysqlAddr string `mapstructure:"mysqlAddr"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
Database string `mapstructure:"database"`
PersonTable string `mapstructure:"personTable"`
- ServePort int `mapstructure:"servePort"`
}
-var DbPersonCompInfo = &database{}
+var MainConf = &mainConfig{}
-type LogConfig struct {
+type logConfig struct {
Path string `mapstructure:"path"` //鏃ュ織瀛樺偍璺緞
Level int `mapstructure:"level"` //鏃ュ織绛夌骇
MaxSize int `mapstructure:"maxSize"` //鏃ュ織鏂囦欢澶у皬涓婇檺
@@ -27,7 +28,7 @@
MaxAge int `mapstructure:"maxAge"` //淇濈暀鍘嬬缉鍖呭ぉ鏁�
}
-var LogConf = &LogConfig{}
+var LogConf = &logConfig{}
func Init() error {
var err error
@@ -36,6 +37,7 @@
v.SetConfigName("compare")
v.AddConfigPath("./")
v.AddConfigPath("./config/")
+ v.AddConfigPath("../config/")
err = v.ReadInConfig()
if err != nil {
fmt.Printf("error on parsing configuration file, %s, config file compare.yaml\n", err.Error())
@@ -52,8 +54,12 @@
}
func read2Conf(v *viper.Viper) {
- v.UnmarshalKey("database", DbPersonCompInfo)
+ v.UnmarshalKey("main", MainConf)
v.UnmarshalKey("log", LogConf)
logger.SetLevel(LogConf.Level)
+
+ if MainConf.WorkerNum == 0 {
+ MainConf.WorkerNum = 30
+ }
}
--
Gitblit v1.8.0