From b36133fcbb12094218c33e35bb225e9dea9b1cf7 Mon Sep 17 00:00:00 2001
From: sunty <1172534965@qq.com>
Date: 星期四, 16 四月 2020 15:10:34 +0800
Subject: [PATCH] fix st server test

---
 controllers/swfsControllers.go |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/controllers/swfsControllers.go b/controllers/swfsControllers.go
index 63ef772..09138f4 100644
--- a/controllers/swfsControllers.go
+++ b/controllers/swfsControllers.go
@@ -91,8 +91,8 @@
 
 func (sc *SeaweedfsController) RestartServerController(c *gin.Context) {
 	StopServer(config.Server.ScriptPath)
-	time.Sleep(time.Second * 1)
 	StartServer(config.Server.ScriptPath)
+	time.Sleep(time.Second * 1)
 	//fmt.Println("GetLocalStartupItem: ", GetLocalStartupItem(config.Server.ScriptPath, StartServerScript))
 	result := strings.Split(GetLocalStartupItem(config.Server.ScriptPath, StartServerScript), "=")[1]
 	fmt.Println("result: ", result)
@@ -101,12 +101,14 @@
 
 //鍚姩鏈嶅姟
 func StartServer(scriptPath string) {
-	util.RunScript("sh " + scriptPath + StartServerScript)
+	//fmt.Println("sh " + scriptPath + "/" + StartServerScript)
+	util.RunScript("sh " + scriptPath + "/" + StartServerScript)
 }
 
 //鍋滄鏈嶅姟
 func StopServer(scriptPath string) {
-	util.RunScript("sh " + scriptPath + StopServerScript)
+	//fmt.Println("sh " + scriptPath + "/" + StopServerScript)
+	util.RunScript("sh " + scriptPath + "/" + StopServerScript)
 }
 
 //鏍规嵁鎼滅储鍐呭鏇挎崲鏁磋鍐呭
@@ -154,13 +156,13 @@
 	url := "http://" + ip + ":7020/node/api-v/swfs/restartServer"
 	var info interface{}
 	httpRes, _ := http.Get(url)
-	defer httpRes.Body.Close()
 	body, _ := ioutil.ReadAll(httpRes.Body)
 	json.Unmarshal(body, &info)
 	res, ok := info.(map[string]interface{})
 	if !ok {
 		fmt.Println("http response interface can not change map[string]interface{}")
 	}
+	fmt.Println("res: ", res)
 	startupItem := res["data"].(string)
 	if httpRes.StatusCode == 200 {
 		startupItem = string(body)
@@ -230,8 +232,11 @@
 			for i := 0; i < len(masterIp); i++ {
 				fmt.Println("len masterIp: ", len(masterIp))
 				fmt.Println("绗�" + strconv.Itoa(i) + "涓嚎绋�")
-				go Restart(masterIp[i], timeOut)
+				fmt.Println("褰撳墠goroutinebe")
 				waitGroup.Add(1) //姣忓垱寤轰竴涓猤oroutine锛屽氨鎶婁换鍔¢槦鍒椾腑浠诲姟鐨勬暟閲�+1
+				fmt.Println("褰撳墠goroutineaf")
+				go Restart(masterIp[i], timeOut)
+				waitGroup.Done()
 			}
 			fmt.Println("杩欓噷涓洪樆濉烇紒锛侊紒锛侊紒")
 			waitGroup.Wait() //.Wait()杩欓噷浼氬彂鐢熼樆濉烇紝鐩村埌闃熷垪涓墍鏈夌殑浠诲姟缁撴潫灏变細瑙i櫎闃诲
@@ -243,8 +248,9 @@
 			if len(peersIp) == i+1 {
 				var waitGroup sync.WaitGroup
 				for i := 0; i < len(masterIp); i++ {
-					go Restart(masterIp[i], timeOut)
 					waitGroup.Add(1) //姣忓垱寤轰竴涓猤oroutine锛屽氨鎶婁换鍔¢槦鍒椾腑浠诲姟鐨勬暟閲�+1
+					go Restart(masterIp[i], timeOut)
+					waitGroup.Done()
 				}
 				waitGroup.Wait() //.Wait()杩欓噷浼氬彂鐢熼樆濉烇紝鐩村埌闃熷垪涓墍鏈夌殑浠诲姟缁撴潫灏变細瑙i櫎闃诲
 				masterIp = make([]string, 0)

--
Gitblit v1.8.0