fix
zhangqian
2023-10-30 10c65da3d2af7056f48d9301e83f53f102f76e18
conf/config.go
@@ -3,7 +3,6 @@
import (
   "apsClient/pkg/convertx"
   "apsClient/pkg/logx"
   "apsClient/pkg/redisx"
   "apsClient/pkg/sqlitex"
   "github.com/spf13/viper"
   "log"
@@ -25,13 +24,6 @@
   System struct {
      Env              string // 环境值 develop test public
      Port             int    // 端口
      DbType           string // 数据库类型
      UseMultipoint    bool   // 多点登录拦截
      UseRedis         bool   // 使用redis
      LimitCountIP     int
      LimitTimeIP      int
      RouterPrefix     string // 路由前缀
      SudoPassword     string // sudo密码
      DeviceId         string //设备id
      NetSetShellPath  string //网络设置脚本路径
      NetUpShellName   string //网络停用脚本
@@ -66,12 +58,27 @@
   Services struct {
      ApsServer string
      Serial    string
   }
   nsqConf struct {
      NodeId         string
      NsqdAddr       string
      NsqlookupdAddr string
   }
   plc struct {
      FinishNumberTimeInterval int
      TotalNumberTimeInterval  int
      ModbusIntType            string
      SlaveId                  int
      Package                  string
      StandbyTime              int64
   }
   Prompt struct {
      SafeProduce     string `json:"safeProduce,omitempty"`
      PlcNotConnected string `json:"plcNotConnected,omitempty"`
   }
   config struct {
@@ -84,22 +91,16 @@
      // mysql配置
      Sqlite sqlitex.Conf
      // redis配置
      Redis redisx.Conf
      // etcd配置
      Etcd Etcd
      // rancher配置
      Rancher Rancher
      // k8s配置
      K8s K8s
      //Services Address
      Services Services
      //NsqConf
      NsqConf nsqConf
      //PLC
      PLC plc
      Prompt Prompt
   }
)
@@ -122,6 +123,9 @@
   if err := Viper.Unmarshal(&Conf); err != nil {
      log.Fatalf("Unmarshal err:%v", err)
   }
   if Conf.PLC.StandbyTime == 0 {
      Conf.PLC.StandbyTime = 300 //5分钟
   }
   ShowConfig()
}
@@ -138,8 +142,7 @@
   log.Println("......................................................")
   log.Printf("   System:                %+v", Conf.System)
   log.Printf("   Log:                   %+v", Conf.Log)
   log.Printf("   etcd:                  %+v", Conf.Etcd)
   log.Printf("   rancher:               %+v", Conf.Rancher)
   log.Printf("   k8s:                   %+v", Conf.K8s)
   log.Printf("   plc :                  %+v", Conf.PLC)
   log.Printf("   services :                  %+v", Conf.Services)
   log.Println("......................................................")
}