panlei
2019-11-30 9c255c93df55e635ecb06535e129efdc72afadaf
main.go
@@ -12,11 +12,11 @@
   "ruleprocess/structure"
   "time"
   "basic.com/valib/logger.git"
   //"basic.com/valib/logger.git"
   "flag"
   "fmt"
   "github.com/spf13/viper"
   log "github.com/jeanphorn/log4go"
   //"github.com/spf13/viper"
   logger "github.com/alecthomas/log4go"
   "ruleprocess/cache"
   "ruleprocess/ruleserver"
   "sync"
@@ -34,18 +34,18 @@
   // 日志初始化
   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)
   //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("日志初始化成功!")
   // log4go
   //log.LoadConfiguration("./logger/log4go.json")
}
func main() {
   //fmt.Println("缓存初始化完成",<- initchan)//dbserver初始化完毕
@@ -63,6 +63,8 @@
   labelFilter.Init()
   go ruleserver.TimeTicker()
   go ruleserver.StartServer()
   //timeEle := ruleserver.TimeElement{N: 300, InitN: 300}
   //ruleserver.TimeEleList["ruleprocess"] = &timeEle
   nReciever("ipc:///tmp/sdk-2-rules-process.ipc", deliver.PushPull, 1)
   wg.Wait()
}
@@ -88,11 +90,10 @@
            fmt.Println("recv error : ", err)
            continue
         } else {
            //runtime.GOMAXPROCS(runtime.NumCPU())
            //logger.Debug("使用的cpu个数:",runtime.NumCPU())
            //go func(msg []byte) {
               logger.Debug("当前时间戳:", time.Now().Unix())
               log.Info(time.Now().Format("2006-01-02 15:04:05"))
               //logger.Warn(time.Now().Format("2006-01-02 15:04:05"))
               arg := structure.SdkDatas{}
               //paramFormat(msg, &arg)
               start := time.Now()
@@ -129,3 +130,5 @@
   mess := f.(func(msg []byte, args *structure.SdkDatas)(protomsg.SdkMessage))(msg,args)
   return mess
}
// 5分钟收不到消息杀死自己重启