liuxiaolong
2019-10-26 f903c085b8adde79c3aeca453a9b935adb1ef033
extend/config/config.go
@@ -1,9 +1,8 @@
package config
import (
   "log"
   "github.com/spf13/viper"
   "log"
)
type server struct {
@@ -11,40 +10,23 @@
   JwtSecret string `mapstructure: "jwtSecret"`
   JwtExpire string `mapstructure: "jwtExpire"`
   Url       string `mapstructure: "url"`
   ImageUrl  string `mapstructure: "imageUrl"`
   PublicDomain string `mapstructure: "publicDomain"`
   AnalyServerId string `mapstructure: "analyServerId"`
   NetworkAdapter string `mapstructure: "networkAdapter"`
   DeviceNum string `mapstructure: "deviceNum"` //设备编号
   DeviceType string `mapstructure: "deviceType"`  //设备型号
   DeviceSerialNum string `mapstructure: "deviceSerialNum"`  //设备序列号
   MasterVersion string `mapstructure: "masterVersion"` //主控版本
   WebVersion string `mapstructure: "webVersion"`  //web版本
   ChannelCount string `mapstructure: "channelCount"`  //通道个数
   DiskCount string `mapstructure: "diskCount"`  //硬盘个数
}
var Server = &server{}
type weedfs struct {
   Ip string `mapstructure: "ip"`
   UploadPort int `mapstructure: "uploadport"`
   VisitPort int `mapstructure: "visitport"`
}
var WeedFs = &weedfs{}
type redis struct {
   Host     string `mapstructure:"host"`
   Port     int    `mapstructure:"port"`
   Password string `mapstructure:"password`
   DBNum    int    `mapstructure:"db"`
}
var RedisConf = &redis{}
type database struct {
   Drive    string `mapstructure:"drive"`
   Name     string `mapstructure:"name"`
   FilePath string `mapstructure:"filepath"`
}
// wp add es 索引 以及 IP port
type esinfo struct {
   Masterip string      `mapstructure:"masterip"`
   Httpport string      `mapstructure:"httpport"`
   Shards string       `mapstructure:"shards"`
   EsIndex  esindexlist `mapstructure:"index"`
}
@@ -54,22 +36,40 @@
   Dbtablepersons index `mapstructure:"dbtablepersons"`
   Personaction   index `mapstructure:"personaction"`
}
type index struct {
   IndexName string `mapstructure:"index"`
   IndexType string `mapstructure:"type"`
}
var EsInfo = &esinfo{}
var DBconf = &database{}
type CompareServer struct {
   Url []string `mapstructure:"url"`
type sopath struct {
   Ip string `mapstructure:"ip"`
   Port string `mapstructure:"port"`
}
var CompServerInfo = &CompareServer{}
var SoPath = &sopath{}
var EsInfo = &esinfo{}
type facedetect struct {
   Ip string `mapstructure:"Ip"`
   Port int `mapstructure:"port"`
}
type dbpersoncompare struct {
   Ip string `mapstructure:"ip"`
   Port int `mapstructure:"port"`
}
type espersoncompare struct {
   Port int `mapstructure:"port"`
   Ips []string `mapstructure:"ips"`
}
var DbPersonCompInfo = &dbpersoncompare{}
var EsCompServerInfo = &espersoncompare{}
var FaceDetectSet = &facedetect{}
// Init is an exported method that takes the environment starts the viper
// (external lib) and returns the configuration struct.
@@ -77,16 +77,15 @@
   var err error
   viper.SetConfigType("yaml")
   viper.SetConfigName(env)
   viper.AddConfigPath("../config/")
   viper.AddConfigPath("config/")
   viper.AddConfigPath("/opt/vasystem/config/")
   err = viper.ReadInConfig()
   if err != nil {
      log.Fatal("error on parsing configuration file")
   }
   viper.UnmarshalKey("es", EsInfo)
   viper.UnmarshalKey("server", Server)
   viper.UnmarshalKey("redis", RedisConf)
   viper.UnmarshalKey("database", DBconf)
   viper.UnmarshalKey("weedfs", WeedFs)
   viper.UnmarshalKey("compare", CompServerInfo)
   viper.UnmarshalKey("sopath",SoPath)
   viper.UnmarshalKey("facedetect", FaceDetectSet)
   viper.UnmarshalKey("dbpersoncompare",DbPersonCompInfo)
   viper.UnmarshalKey("espersoncompare", EsCompServerInfo)
}