From 2ea23e2364f742f528fb8b97657212c174d1bbd7 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期六, 21 十月 2023 14:06:59 +0800 Subject: [PATCH] 增加切换serf状态接口(调试用) --- main.go | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/main.go b/main.go index 74d4c67..7acd081 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ "apsClient/serf" "apsClient/service/plc_address" "fmt" + "log" "net/http" "time" ) @@ -30,6 +31,7 @@ // 鍚姩鏁版嵁鍚屾 var serfStartChan = make(chan bool) + // 闇�瑕佸悓姝ョ殑琛� var syncTables = []string{ "procedures", @@ -37,14 +39,23 @@ "production_progress", "work_order", "task_status_sync", + "device", + "device_plc", } agent := serf.InitAgent("apsClient", syncTables, sqlitex.GetDB()) agent.RegisterClusterEvent(serfClusterEvent) + go agent.Serve(serfStartChan) <-serfStartChan + //if !<-serfStartChan { + // logx.Errorf("serf Init err, exit") + // return + //} // 鍒ゆ柇褰撳墠闆嗙兢鐘舵�� + logx.Infof("current agent.ClusterStatus:%v", agent.ClusterStatus) + log.Println("current agent.ClusterStatus:", agent.ClusterStatus) if agent.ClusterStatus != "slave" { if err := nsq.Init(); err != nil { logx.Errorf("nsq Init err:%v", err) -- Gitblit v1.8.0