上传配置中心没有定时校验bug

This commit is contained in:
liwei 2022-09-19 17:23:54 +08:00
parent 8cf0ee5890
commit 714da99c01
4 changed files with 25 additions and 16 deletions

View File

@ -9,13 +9,14 @@
if [ $num -eq 0 ]
then
nohup $CMD > /dev/null 2>&1 &
# nohup $CMD >output.log 2>&1 &
#nohup $CMD > $SERVICE.log 2>&1 &
if [ $? -ne 0 ]
then
echo "start failed, please check the log!"
exit $?
else
echo $! > $SERVICE.pid
# echo $! > $SERVICE.pid
echo "start success"
fi
else
@ -26,13 +27,14 @@
}
stop(){
echo "stopping $SERVICE..."
kill -9 `cat $SERVICE.pid`
#kill -9 `cat $SERVICE.pid`
kill -9 `ps -ef | grep $SERVICE | grep conf | awk '{print $2}'`
if [ $? -ne 0 ]
then
echo "stop failed, may be $SERVICE isn't running"
exit $?
else
rm -rf $SERVICE.pid
#rm -rf $SERVICE.pid
echo "stop success"
fi
}

View File

@ -155,7 +155,10 @@ func (this *AgentMgrComp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadC
}
this.module.Debugf("SendMsgToAllAgent: msg:%v", msg)
this.agents.Range(func(key, value any) bool {
value.(IAgent).WriteMsg(msg)
agent := value.(IAgent)
if agent.UserId() != "" { //只发送登录用户
agent.WriteMsg(msg)
}
return true
})
return nil

View File

@ -12,6 +12,7 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/cron"
"go_dreamfactory/lego/sys/log"
"google.golang.org/protobuf/types/known/anypb"
)
@ -52,29 +53,28 @@ func (this *ChatComp) Start() (err error) {
} else {
var id cron.EntryID
this.takes = make([]cron.EntryID, 0)
for _, v := range v.(*cfg.GameChatSystem).GetDataList() {
if v.Type == int32(comm.TimedNotice) { //处理定时任务
confs := v.(*cfg.GameChatSystem)
for k, v1 := range confs.GetDataMap() {
if v1.Type == int32(comm.TimedNotice) { //处理定时任务
weekStr := ""
for _, w := range v.Week {
for _, w := range v1.Week {
weekStr += fmt.Sprintf("%d,", w)
}
if len(weekStr) > 0 && len(weekStr) < 7 {
if len(v1.Week) > 0 && len(v1.Week) < 7 {
weekStr = weekStr[0 : len(weekStr)-1]
} else {
weekStr = "*"
}
cronStr := fmt.Sprintf("* %d %d * * %s", v.TimeM, v.TimeH, weekStr)
if id, err = cron.AddFunc(cronStr, this.chatNoticen(v)); err != nil {
cronStr := fmt.Sprintf("* %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 {
this.module.Errorf("cron.AddFunc:%s err:%v", cronStr, err)
continue
}
this.takes = append(this.takes, id)
}
}
//测试代码
// if id, err = cron.AddFunc("0 */1 * * * ?", this.chatNoticen(&cfg.GameChatSystemData{Text: "测试公告系统"})); err != nil {
// this.module.Errorf("cron.AddFunc:%s err:%v", "0 */1 * * * ?", err)
// }
}
})
return
@ -89,6 +89,7 @@ func (this *ChatComp) chatNoticen(n *cfg.GameChatSystemData) func() {
Content: n.Text,
}
data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})
this.module.Debug("广播公告消息", log.Field{Key: "chat", Value: msg})
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",

View File

@ -47,7 +47,6 @@ type Configure struct {
func (this *Configure) Start() (err error) {
timer := time.NewTicker(time.Second * time.Duration(this.options.CheckInterval))
defer timer.Stop()
go func() {
locp:
for {
@ -58,6 +57,7 @@ func (this *Configure) Start() (err error) {
this.checkConfigure()
}
}
timer.Stop()
}()
return
@ -177,6 +177,7 @@ func (this *Configure) loaderConfigure(name string, handle *configurehandle) (er
//检查配置文件是否有更新
func (this *Configure) checkConfigure() {
log.Debug("Check Configure Update")
if dir, err := ioutil.ReadDir(this.options.ConfigurePath); err != nil {
log.Errorf("[Configure Sys] checkConfigure err:%v", err)
} else {
@ -190,8 +191,10 @@ func (this *Configure) checkConfigure() {
handle := this.configurehandles[v.Name]
this.hlock.RUnlock()
if err = this.loaderConfigure(v.Name, handle); err != nil {
log.Errorln(err)
return
}
log.Debug("UpDate Configure", log.Field{Key: "table", Value: v.Name})
for _, v := range handle.events {
if v != nil {
go func(f func()) {