sunty
2020-04-16 fa96e243e2adc6a72f41dbab7152e0312c657733
controllers/swfsControllers.go
@@ -118,11 +118,16 @@
//更新所有节点的脚本参数
func UpdateAllNodesScriptArgument(peersIp []string) {
   fmt.Println("开始更新本地配置文件")
   for _, ip := range peersIp {
      fmt.Println("ip: ", ip)
      url := "http://" + ip + ":7020/node/api-v/swfs/updateSWFSService"
      fmt.Println("url", url)
      http.Get(url)
      resp, _ := http.Get(url)
      fmt.Println("更新返回状态:", resp.StatusCode)
      if resp.StatusCode == 200 {
         fmt.Println("请求完毕", resp.StatusCode)
      }
   }
}
@@ -154,8 +159,11 @@
      startupItem = string(body)
   }
   tick := time.Tick(1 * time.Second)
   fmt.Println("准备开始验证节点服务")
   for countdown := timeOut; countdown > 0; countdown-- {
      fmt.Println("第一次验证")
      result := Verification(startupItem, ip)
      fmt.Println("第一次验证result结果:", result)
      if result == true {
         break
      }
@@ -200,14 +208,20 @@
//构建重启流程
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
   fmt.Println("当前并行度coreThread:", coreThread)
   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++ {
            fmt.Println("len masterIp: ", len(masterIp))
            fmt.Println("第" + strconv.Itoa(i) + "个线程")
            go Restart(masterIp[i], timeOut)
            waitGroup.Add(1) //每创建一个goroutine,就把任务队列中任务的数量+1
         }
@@ -226,7 +240,6 @@
            break
         }
      }
      continue
   }
}