use one config with other proc
| | |
| | | JwtSecret string `mapstructure: "jwtSecret"` |
| | | JwtExpire string `mapstructure: "jwtExpire"` |
| | | Url string `mapstructure: "url"` |
| | | AnalyServerId string `mapstructure: "analyServerId"` |
| | | ImageUrl string `mapstructure: "imageUrl"` |
| | | PublicDomain string `mapstructure: "publicDomain"` |
| | | NetworkAdapter string `mapstructure: "networkAdapter"` |
| | |
| | | |
| | | 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"` |
| | |
| | | type esinfo struct { |
| | | Masterip string `mapstructure:"masterip"` |
| | | Httpport string `mapstructure:"httpport"` |
| | | Shards string `mapstructure:"shards"` |
| | | EsIndex esindexlist `mapstructure:"index"` |
| | | } |
| | | |
| | |
| | | var DBconf = &database{} |
| | | |
| | | type facedetect struct { |
| | | Url string `mapstructure:"url"` |
| | | Ip string `mapstructure:"Ip"` |
| | | Port int `mapstructure:"port"` |
| | | } |
| | | |
| | | type dbpersoncompare struct { |
| | | Url string `mapstructure:"url"` |
| | | Ip string `mapstructure:"ip"` |
| | | Port int `mapstructure:"port"` |
| | | } |
| | | |
| | | type espersoncompare struct { |
| | | Url []string `mapstructure:"url"` |
| | | Port int `mapstructure:"port"` |
| | | Ips []string `mapstructure:"ips"` |
| | | } |
| | | |
| | | var DbPersonCompInfo = &dbpersoncompare{} |
| | |
| | | var err error |
| | | viper.SetConfigType("yaml") |
| | | viper.SetConfigName(env) |
| | | viper.AddConfigPath("../config/") |
| | | viper.AddConfigPath("config/") |
| | | 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("server", Server) |
| | | viper.UnmarshalKey("redis", RedisConf) |
| | | viper.UnmarshalKey("database", DBconf) |
| | | viper.UnmarshalKey("weedfs", WeedFs) |
| | | viper.UnmarshalKey("sopath",SoPath) |
| | |
| | | |
| | | import ( |
| | | "basic.com/dbapi.git" |
| | | "basic.com/valib/logger.git" |
| | | "flag" |
| | | "github.com/golang/glog" |
| | | "github.com/robfig/cron" |
| | | "github.com/spf13/viper" |
| | | "strconv" |
| | | "webserver/extend/config" |
| | | "basic.com/valib/logger.git" |
| | | "webserver/router" |
| | | "webserver/service" |
| | | ) |
| | | |
| | | var envirment = flag.String("e", "dev", "") |
| | |
| | | var dbPort = flag.String("dbPort", "8001", "default dbPort=8001") |
| | | |
| | | func init() { |
| | | var logFile = "./logger/webserver.log" |
| | | var logSaveDays = 15 |
| | | |
| | | // 日志初始化 |
| | | logger.Config(logFile, logger.DebugLevel) |
| | | logger.SetSaveDays(logSaveDays) |
| | | logger.Info("loginit success !") |
| | | flag.Parse() |
| | | //service.InitService() |
| | | |
| | |
| | | if err != nil { |
| | | p = 8001 |
| | | } |
| | | //*dbIp = "192.168.1.123" |
| | | //*dbIp = "192.168.1.182" |
| | | dbapi.Init(*dbIp, p) |
| | | |
| | | var logFile = "./logger/" |
| | | if viper.GetString("LogBasePath") != "" { |
| | | logFile = viper.GetString("LogBasePath") |
| | | } |
| | | logFile = logFile + "/webserver.log" |
| | | var logSaveDays = 15 |
| | | |
| | | // 日志初始化 |
| | | if viper.IsSet("LogLevel") && |
| | | viper.GetInt("LogLevel") >= logger.PanicLevel && |
| | | viper.GetInt("LogLevel") <= logger.DebugLevel { |
| | | logger.Config(logFile, viper.GetInt("LogLevel")) |
| | | }else{ |
| | | logger.Config(logFile, logger.DebugLevel) |
| | | } |
| | | logger.SetSaveDays(logSaveDays) |
| | | logger.Info("loginit success !") |
| | | |
| | | flag.Usage = func() { |
| | | glog.Exit("flag parse usage !") |
| | |
| | | config.Init(*envirment) |
| | | } |
| | | func main() { |
| | | c := cron.New() |
| | | c.AddFunc("@ daily", func() { |
| | | res := service.InitEnableStatus() |
| | | logger.Debug(res) |
| | | }) |
| | | c.Start() |
| | | r := router.NewRouter() |
| | | r.Run("0.0.0.0:8000") |
| | | |
| | | //defer new(gorun.SimpleFaceDetect).FaceDetactClose() |
| | | } |
| | |
| | | if camera.Type == 1{//国标摄像机 |
| | | m = capture.GB28181 |
| | | } |
| | | b,err := capture.Capture("./runtime/libcffmpeg.so",m,camera.Rtsp,capture.JPEGFileExt,1280,720,10) |
| | | b,err := capture.Capture("libcffmpeg.so",m,camera.Rtsp,capture.JPEGFileExt,1280,720,10) |
| | | if err == nil{ |
| | | var weedfsUri = "http://"+config.WeedFs.Ip+":"+strconv.Itoa(config.WeedFs.UploadPort)+"/submit" |
| | | weedFilePath, err := WeedFSClient.UploadFile(weedfsUri, camera.Name+".jpg", b) |
| | |
| | | "basic.com/pubsub/protomsg.git" |
| | | "context" |
| | | "errors" |
| | | "strconv" |
| | | "time" |
| | | "webserver/extend/config" |
| | | "basic.com/valib/logger.git" |
| | |
| | | ) |
| | | |
| | | func DoFDetectWithRpc(fdr *protomsg.FaceDetectRequest,t time.Duration) ([]*protomsg.ResultFaceDetect,error) { |
| | | conn,err := grpc.Dial(config.FaceDetectSet.Url, grpc.WithInsecure()) |
| | | fdUrl:=config.FaceDetectSet.Ip + ":" + strconv.Itoa(config.FaceDetectSet.Port) |
| | | conn,err := grpc.Dial(fdUrl, grpc.WithInsecure()) |
| | | if err !=nil { |
| | | logger.Debug("grpc dial err:",err) |
| | | } |
| | |
| | | "nanomsg.org/go-mangos/protocol/req" |
| | | "nanomsg.org/go-mangos/transport/ipc" |
| | | "nanomsg.org/go-mangos/transport/tcp" |
| | | "strconv" |
| | | "sync" |
| | | "webserver/extend/config" |
| | | "basic.com/valib/logger.git" |
| | |
| | | func (sv *FaceCompareService) CompareVideoPersons() *CompareList{ |
| | | sv.CompareArgs.TableIds = []string { CaptureTable } |
| | | b, err := proto.Marshal(&sv.CompareArgs) |
| | | esCompServerList := config.EsCompServerInfo.Url |
| | | esCompServerList := config.EsCompServerInfo.Ips |
| | | logger.Debug("compServerList:", esCompServerList) |
| | | //1.向各个Es compare进程发起请求拿到比对结果 |
| | | var resultList CompareList |
| | | |
| | | for _,str :=range esCompServerList{ |
| | | reqUrl := "tcp://"+str |
| | | reqUrl := "tcp://"+str + ":"+strconv.Itoa(config.EsCompServerInfo.Port) |
| | | resultB := doCompareRequest(reqUrl,b) |
| | | if resultB == nil || len(*resultB) ==0 { |
| | | continue |
| | |
| | | //比对底库 |
| | | func (sv *FaceCompareService) CompareDbPersons() *CompareList{ |
| | | b, err := proto.Marshal(&sv.CompareArgs) |
| | | dbPersonCompServerUrl := config.DbPersonCompInfo.Url |
| | | dbPersonCompServerUrl := config.DbPersonCompInfo.Ip |
| | | logger.Debug("comp Server url:", dbPersonCompServerUrl) |
| | | |
| | | var resultList CompareList |
| | | |
| | | reqUrl := "tcp://"+dbPersonCompServerUrl |
| | | reqUrl := "tcp://"+dbPersonCompServerUrl+":"+strconv.Itoa(config.DbPersonCompInfo.Port) |
| | | resultB := doCompareRequest(reqUrl,b) |
| | | if resultB == nil || len(*resultB) ==0 { |
| | | return nil |