zhangzengfei
2023-11-28 3a706d3378aa3626501370352963883fd2783558
system-service/main.go
@@ -3,6 +3,7 @@
import (
   "context"
   "flag"
   "fmt"
   _ "net/http/pprof"
   "os"
   "os/signal"
@@ -60,7 +61,7 @@
      Proc:        *proc,
      Channel:     nil,
      PubTopic:    pubTopics,
      SubTopic:    []string{versionControlS.AuthorizationUpdateTopic},
      SubTopic:    []string{versionControlS.AuthorizationUpdateTopic, "sync-proc-message-to-serf"},
      SubNetTopic: []string{},
   }
@@ -74,7 +75,7 @@
   bhomedbapi.InitGetNetNode(ms.GetLocalNetNodeByTopic)
   bhomedbapi.InitDoReq(ms.RequestOnly)
   //bhomedbapi.InitLog(logger.Debug)
   bhomedbapi.InitLog(logger.Debug)
   //util.AuthCheck(ctx) //授权检查
@@ -155,6 +156,7 @@
   funcMap[urlPrefix+"/sysset/getWifiList"] = ssController.GetWifiList
   funcMap[urlPrefix+"/sysset/getDefKeyboardLayout"] = ssController.GetDefKeyboardLayout
   funcMap[urlPrefix+"/sysset/connectWifi"] = ssController.ConnectWifi
   funcMap[urlPrefix+"/sysset/disconnectWifi"] = ssController.DisonnectWifi
   funcMap[urlPrefix+"/sysset/getSysSetting"] = ssController.GetSysSetting
   funcMap[urlPrefix+"/sysset/updateSysSetting"] = ssController.UpdateSysSetting
   funcMap[urlPrefix+"/sysset/freedisk"] = ssController.DiskInfo
@@ -177,6 +179,8 @@
   funcMap[urlPrefix+"/cluster/updateClusterName"] = clusterController.UpdateClusterName
   funcMap[urlPrefix+"/cluster/leave"] = clusterController.Leave
   funcMap[urlPrefix+"/cluster/findIpByNode"] = clusterController.FindIpByNode
   funcMap[urlPrefix+"/cluster/status"] = clusterController.GetClusterStat
   funcMap[urlPrefix+"/cluster/update2Master"] = clusterController.Update2Master
   sysMenuC := new(controllers.SysMenuController)
   funcMap["/data/api-u/sysmenus/tree"] = sysMenuC.MenuTree
@@ -270,17 +274,19 @@
   for key, _ := range funcMap {
      pubTopics = append(pubTopics, key)
   }
   return funcMap, pubTopics
}
// 测试接收全网消息
func dealSubMsg(ctx context.Context, ms *bhomeclient.MicroNode) {
   fmt.Println("dealSubMsg")
   for {
      select {
      case <-ctx.Done():
         return
      case msg := <-ms.SubCh:
         logger.Debug("recv sub msg topic:", string(msg.Topic), " data:", string(msg.Data))
         logger.Debug("recv sub msg topic:", string(msg.Topic), " data len:", len(msg.Data))
         service.PersistentWrapper(string(msg.Topic), msg.Data)
      }
   }