上传定时公告多次触发bug

This commit is contained in:
liwei 2022-09-19 18:42:31 +08:00
parent 714da99c01
commit 8ce2eb637a
2 changed files with 7 additions and 9 deletions

View File

@ -55,7 +55,7 @@ func (this *ChatComp) Start() (err error) {
this.takes = make([]cron.EntryID, 0)
confs := v.(*cfg.GameChatSystem)
for k, v1 := range confs.GetDataMap() {
for _, v1 := range confs.GetDataMap() {
if v1.Type == int32(comm.TimedNotice) { //处理定时任务
weekStr := ""
for _, w := range v1.Week {
@ -66,9 +66,9 @@ func (this *ChatComp) Start() (err error) {
} else {
weekStr = "*"
}
cronStr := fmt.Sprintf("* %d %d * * %s", v1.TimeM, v1.TimeH, weekStr)
cronStr := fmt.Sprintf("0 %d %d ? * %s", v1.TimeM, v1.TimeH, weekStr)
this.module.Debug("注册Chat广播公告消息", log.Field{Key: "cronStr", Value: cronStr}, log.Field{Key: "text", Value: v1.Text})
if id, err = cron.AddFunc(cronStr, this.chatNoticen(confs.GetDataMap()[k])); err != nil {
if id, err = cron.AddFunc(cronStr, this.chatNoticen(v1.Text)); err != nil {
this.module.Errorf("cron.AddFunc:%s err:%v", cronStr, err)
continue
}
@ -80,24 +80,22 @@ func (this *ChatComp) Start() (err error) {
return
}
func (this *ChatComp) chatNoticen(n *cfg.GameChatSystemData) func() {
func (this *ChatComp) chatNoticen(content string) func() {
return func() {
msg := &pb.DBChat{
Channel: pb.ChatChannel_System,
Stag: this.service.GetTag(),
Ctime: time.Now().Unix(),
Content: n.Text,
Content: content,
}
data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})
this.module.Debug("广播公告消息", log.Field{Key: "chat", Value: msg})
this.module.Debug("广播公告消息", log.Field{Key: "chat", Value: content})
if err := this.module.service.AcrossClusterBroadcast(context.Background(), msg.Stag, comm.Service_Gateway, string(comm.Rpc_GatewaySendRadioMsg), pb.UserMessage{
MainType: string(comm.ModuleChat),
SubType: "message",
Data: data,
}, nil); err != nil {
this.module.Errorf("err:%v", err)
} else {
this.module.Debugf("chatNoticen:%s", n.Text)
}
}
}

View File

@ -177,7 +177,7 @@ func (this *Configure) loaderConfigure(name string, handle *configurehandle) (er
//检查配置文件是否有更新
func (this *Configure) checkConfigure() {
log.Debug("Check Configure Update")
// log.Debug("Check Configure Update")
if dir, err := ioutil.ReadDir(this.options.ConfigurePath); err != nil {
log.Errorf("[Configure Sys] checkConfigure err:%v", err)
} else {