From cd60b7e3a0bbc09f4501f66260b5d961d58aaf49 Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期二, 17 十二月 2019 13:38:07 +0800 Subject: [PATCH] --- --- main.go | 64 ++++++++++++++++++++----------- 1 files changed, 41 insertions(+), 23 deletions(-) diff --git a/main.go b/main.go index 935a091..50af134 100644 --- a/main.go +++ b/main.go @@ -3,13 +3,16 @@ import ( "flag" + "fmt" + "github.com/spf13/viper" "sync" "net/http" _ "net/http/pprof" "plugin" //"github.com/spf13/viper" - logger "github.com/alecthomas/log4go" + //"basic.com/valib/logger.git" + "basic.com/valib/logger.git" "github.com/panjf2000/ants/v2" "basic.com/pubsub/protomsg.git" @@ -32,18 +35,18 @@ flag.Parse() // 鏃ュ織鍒濆鍖� - insertdata.Init(*env) - //var logFile = "./logger/" - //if viper.GetString("LogBasePath") != "" { - // logFile = viper.GetString("LogBasePath") - //} - //logFile = logFile + "ruleprocess.log" - //fmt.Println("鏃ュ織鍦板潃锛�",logFile) - //logger.Config(logFile, logger.DebugLevel) - //logger.SetSaveDays(7) + structure.Init(*env) + var logFile = "./logger/" + if viper.GetString("LogBasePath") != "" { + logFile = viper.GetString("LogBasePath") + } + logFile = logFile + "ruleprocess.log" + fmt.Println("鏃ュ織鍦板潃锛�",logFile) + logger.Config(logFile, logger.DebugLevel) + logger.SetSaveDays(7) // log4go - logger.LoadConfiguration("./logger/log.xml") - logger.Info("鏃ュ織鍒濆鍖栨垚鍔燂紒") + //logger.LoadConfiguration("./logger/log.xml") + logger.Info("鏃ュ織鍒濆鍖栨垚鍔燂紒",logFile) } func main() { @@ -63,7 +66,7 @@ go ruleserver.TimeTicker() go ruleserver.StartServer() - + personTrackPush() nReciever("ipc:///tmp/sdk-2-rules-process.ipc", deliver.PushPull, 1) wg.Wait() @@ -75,20 +78,23 @@ func nRecvImpl(c deliver.Deliver, index int) { var msg []byte - var wg1 sync.WaitGroup - p,_ := ants.NewPool(100) - syncCalculateSum := func() { - Task(msg) - wg1.Done() - } - wg1.Wait() + //var wg1 sync.WaitGroup + //p,_ := ants.NewPool(20) + //syncCalculateSum := func() { + // Task(msg) + // wg1.Done() + //} + //wg1.Wait() var err error for { msg, err = c.Recv() if err == nil { - wg1.Add(1) - _ = p.Submit(syncCalculateSum) - //go Task(msg) + //wg1.Add(1) + //_ = p.Submit(syncCalculateSum) + Task(msg) + } else { + //fmt.Println(err) + //logger.Info(err) } } } @@ -120,4 +126,16 @@ mess := f.(func(msg []byte, args *structure.SdkDatas)(protomsg.SdkMessage))(msg,args) return mess } +// 鍚姩杩借釜鐨勮姹� +func personTrackPush(){ + p,err := plugin.Open("./algorithm/personTrack.so") + if err != nil { + panic(err) + } + f,err1 := p.Lookup("Push") + if err1 != nil { + panic("鍒濆鍖栦汉鍛樿拷韪殑鎺ㄩ�佸嚱鏁�") + } + go f.(func()())() +} -- Gitblit v1.8.0