New file |
| | |
| | | package insertdata |
| | | |
| | | import ( |
| | | "github.com/spf13/viper" |
| | | "log" |
| | | ) |
| | | |
| | | |
| | | |
| | | |
| | | type weedfs struct { |
| | | Ip string `mapstructure: "ip"` |
| | | UploadPort int `mapstructure: "uploadport"` |
| | | VisitPort int `mapstructure: "visitport"` |
| | | } |
| | | |
| | | var WeedFs = &weedfs{} |
| | | |
| | | // wp add es 索引 以及 IP port |
| | | type esinfo struct { |
| | | Masterip string `mapstructure:"masterip"` |
| | | Httpport string `mapstructure:"httpport"` |
| | | Shards string `mapstructure:"shards"` |
| | | EsIndex esindexlist `mapstructure:"index"` |
| | | } |
| | | |
| | | type esindexlist struct { |
| | | VideoPersons index `mapstructure:"videopersons"` |
| | | DbTables index `mapstructure:"dbtables"` |
| | | Dbtablepersons index `mapstructure:"dbtablepersons"` |
| | | Personaction index `mapstructure:"personaction"` |
| | | } |
| | | type index struct { |
| | | IndexName string `mapstructure:"index"` |
| | | IndexType string `mapstructure:"type"` |
| | | } |
| | | |
| | | type sopath struct { |
| | | Ip string `mapstructure:"ip"` |
| | | Port string `mapstructure:"port"` |
| | | } |
| | | |
| | | var SoPath = &sopath{} |
| | | |
| | | var EsInfo = &esinfo{} |
| | | |
| | | // Init is an exported method that takes the environment starts the viper |
| | | // (external lib) and returns the configuration struct. |
| | | func Init(env string) { |
| | | var err error |
| | | viper.SetConfigType("yaml") |
| | | viper.SetConfigName(env) |
| | | viper.AddConfigPath("/opt/vasystem/config/") |
| | | viper.AddConfigPath("") |
| | | err = viper.ReadInConfig() |
| | | if err != nil { |
| | | log.Fatal("error on parsing configuration file") |
| | | } |
| | | viper.UnmarshalKey("es", EsInfo) |
| | | viper.UnmarshalKey("weedfs", WeedFs) |
| | | viper.UnmarshalKey("sopath",SoPath) |
| | | } |
| | |
| | | "encoding/json" |
| | | "errors" |
| | | "fmt" |
| | | "io/ioutil" |
| | | "net" |
| | | "ruleprocess/cache" |
| | | "ruleprocess/logger" |
| | |
| | | "time" |
| | | |
| | | "basic.com/pubsub/protomsg.git" |
| | | "github.com/go-yaml/yaml" |
| | | "github.com/golang/protobuf/proto" |
| | | "github.com/satori/go.uuid" |
| | | "ruleprocess/ruleserver" |
| | |
| | | } |
| | | |
| | | func init() { |
| | | data, err := ioutil.ReadFile("./config/conf.yml") |
| | | if err != nil { |
| | | fmt.Println("读取配置文件出错--", err) |
| | | logger.Error("读取配置文件出错--", err) |
| | | } |
| | | c := conf{} |
| | | //把yaml形式的字符串解析成struct类型 |
| | | yaml.Unmarshal(data, &c) |
| | | weedfsUrl = c.PhotoUrl |
| | | videoPersonUrl = c.VideoPersons |
| | | personAction = c.PersonAction |
| | | weedfsUrl = "http://"+WeedFs.Ip+":"+strconv.Itoa(WeedFs.UploadPort)+"/submit" |
| | | videoPersonUrl = "http://"+EsInfo.Masterip+":"+EsInfo.Httpport+"/"+EsInfo.EsIndex.VideoPersons.IndexName+"/"+EsInfo.EsIndex.VideoPersons.IndexType |
| | | personAction = "http://"+EsInfo.Masterip+":"+EsInfo.Httpport+"/"+EsInfo.EsIndex.Personaction.IndexName+"/"+EsInfo.EsIndex.Personaction.IndexType |
| | | } |
| | | |
| | | // 人脸的数据结构 |
| | |
| | | var surveyPort = flag.Int("surveyPort", 40007, "survey port") //心跳 |
| | | var pubPort = flag.Int("pubPort", 50007, "pubsub port") //数据更新 |
| | | var initchan = make(chan bool) |
| | | var env = flag.String("env","pro","env set") |
| | | |
| | | func init() { |
| | | flag.Parse() |
| | | // 日志初始化 |
| | | logger.Config("./info.log", logger.DebugLevel) |
| | | logger.Info("日志初始化成功!") |
| | | |
| | | insertdata.Init(*env) |
| | | } |
| | | func main() { |
| | | //fmt.Println("缓存初始化完成",<- initchan)//dbserver初始化完毕 |
| | |
| | | |
| | | import ( |
| | | "basic.com/dbapi.git" |
| | | bigCache "basic.com/pubsub/cache.git" |
| | | "basic.com/pubsub/protomsg.git" |
| | | "encoding/json" |
| | | "errors" |
| | |
| | | if err1 != nil { |
| | | logger.Error("查询本机信息失败!") |
| | | } |
| | | logger.Debug("本机信息和server信息:", localConfig, serverIp, serverPort) |
| | | bigCache.Init(dbTablePersons, serverIp, serverPort, localConfig.ServerId) |
| | | //logger.Debug("本机信息和server信息:", localConfig, serverIp, serverPort) |
| | | //bigCache.Init(dbTablePersons, serverIp, serverPort, localConfig.ServerId) |
| | | go Push1() |
| | | } |
| | | |