sunty
2020-04-16 9ab77756aac42171f72c3aa44d1a16b5bf6ce191
controllers/swfsControllers.go
@@ -122,7 +122,10 @@
      fmt.Println("ip: ", ip)
      url := "http://" + ip + ":7020/node/api-v/swfs/updateSWFSService"
      fmt.Println("url", url)
      http.Get(url)
      resp, _ := http.Get(url)
      if resp.StatusCode == 200 {
         fmt.Println("请求完毕", resp.StatusCode)
      }
   }
}
@@ -154,7 +157,9 @@
      startupItem = string(body)
   }
   tick := time.Tick(1 * time.Second)
   fmt.Println("准备开始验证节点服务")
   for countdown := timeOut; countdown > 0; countdown-- {
      fmt.Println("第一次验证")
      result := Verification(startupItem, ip)
      if result == true {
         break
@@ -200,13 +205,16 @@
//构建重启流程
func RestartAllServer(peersIp []string, coreBaseUnit int) {
   fmt.Println("开始构建重启流程")
   coreThread := len(peersIp)/coreBaseUnit + 1
   masterIp := make([]string, 0)
   timeOut, _ := strconv.Atoi(config.Server.TimeOut)
   var waitGroup sync.WaitGroup
   for i, ip := range peersIp {
      fmt.Println("重启第一组服务" + ip)
      if (i+1)%coreThread == 0 {
         masterIp = append(masterIp, strings.Split(ip, ":")[0])
         fmt.Println("加入第一组并开始验证第一组 masterIp: ", masterIp)
         for i := 0; i < len(masterIp); i++ {
            go Restart(masterIp[i], timeOut)
            waitGroup.Add(1) //每创建一个goroutine,就把任务队列中任务的数量+1