|
@@ -67,6 +67,9 @@ func (d *DataEventEntry) SubMsgLog(configOption *config.AppConfig, client golang
|
|
|
sc := make(chan os.Signal, 1)
|
|
|
signal.Notify(sc, os.Kill, os.Interrupt, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
|
|
|
|
|
|
+ // 设置5分钟超时
|
|
|
+ tc := time.After(5 * time.Minute)
|
|
|
+
|
|
|
//for i := 0; i < int(configOption.WorkNumber); i++ {
|
|
|
//go func() {
|
|
|
for {
|
|
@@ -98,6 +101,16 @@ func (d *DataEventEntry) SubMsgLog(configOption *config.AppConfig, client golang
|
|
|
DSMLog.Mx.Unlock()
|
|
|
}
|
|
|
close(subMsgChan)
|
|
|
+ case <-tc:
|
|
|
+ if len(DSMLog.SubMsgLogList) > 0 {
|
|
|
+ DSMLog.Mx.Lock()
|
|
|
+ if err := d.DB.Create(DSMLog.SubMsgLogList).Error; err != nil {
|
|
|
+ zaplog.Error("subMsgChan-os", zap.Any("err", err), zap.Any("subMsgLog", DSMLog.SubMsgLogList))
|
|
|
+ }
|
|
|
+ zaplog.Info("subMsgChan-os", zap.Any("success", DSMLog.SubMsgLogList))
|
|
|
+ DSMLog.SubMsgLogList = make([]*model.SubMsgLog, 0)
|
|
|
+ DSMLog.Mx.Unlock()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|