From 6afbcd88bf9c2c14a16a7c01f6f2e269d4ea2883 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 01 十一月 2023 15:53:30 +0800 Subject: [PATCH] fix --- crontask/cron_task.go | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/crontask/cron_task.go b/crontask/cron_task.go index cd4e9e6..66ddf9b 100644 --- a/crontask/cron_task.go +++ b/crontask/cron_task.go @@ -7,6 +7,7 @@ "apsClient/nsq" "apsClient/pkg/ecode" "apsClient/pkg/logx" + "apsClient/serf" "apsClient/service" "fmt" "github.com/go-co-op/gocron" @@ -79,6 +80,9 @@ s.Every(60).Seconds().Do(SyncProductionProgress) //鍚屾鐢熶骇鏁版嵁 s.Every(30).Seconds().Do(SyncTaskStatus) //鍚屾浠诲姟鐘舵�� } + + s.Every(10).Seconds().Do(QueryClusterStatus) //鏌ヨ闆嗙兢鑺傜偣鏁伴噺 + s.StartAsync() return nil } @@ -143,11 +147,18 @@ caller := nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicPullDataRequest, conf.Conf.NsqConf.NodeId), constvar.NsqTopicPullDataResponse) err := caller.Send(msg) if err != nil { - logx.Errorf("send pull data msg error:%v", err.Error()) + logx.Errorf("send pull data msg error:%v, msg:%+v", err.Error(), msg) } - caller = nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicGetPlcAddress, conf.Conf.NsqConf.NodeId), "") - err = caller.Send(common.RequestPlcAddress{DeviceId: conf.Conf.System.DeviceId}) + msg = &common.MsgPullDataRequest{DataType: common.PullDataTypeDevice} + caller = nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicPullDataRequest, conf.Conf.NsqConf.NodeId), constvar.NsqTopicPullDataResponse) + err = caller.Send(msg) if err != nil { - logx.Infof("get plc address err: %v", err.Error()) + logx.Errorf("send pull data msg error:%v, msg:%+v", err.Error(), msg) } } + +func QueryClusterStatus() { + clusterStatus, nodeQuantity := serf.QueryClusterStatusAndNodeQuantity() + conf.Conf.SerfClusterStatus = clusterStatus + conf.Conf.ClusterNodeQuantity = nodeQuantity +} -- Gitblit v1.8.0