From e2ca6ba654f1371f3b375392e29e3fa070ad96ce Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期四, 16 四月 2020 15:25:48 +0800 Subject: [PATCH] fix startup item --- controllers/swfsControllers.go | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/controllers/swfsControllers.go b/controllers/swfsControllers.go index 98f2f49..8f3fb76 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,17 +156,18 @@ 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) } + fmt.Println("Restart startupItem: ", startupItem) tick := time.Tick(1 * time.Second) fmt.Println("鍑嗗寮�濮嬮獙璇佽妭鐐规湇鍔�") for countdown := timeOut; countdown > 0; countdown-- { @@ -182,9 +185,10 @@ //楠岃瘉鏈嶅姟鐘舵�� func Verification(startupItem string, ip string) bool { resStatu := false + fmt.Println("Verification startupItem: ", startupItem) switch startupItem { case StartScriptAsVolume: - verificationVolumeUrl := "http://" + ip + ":6700" + verificationVolumeUrl := "http://" + ip + ":6700/ui/index.html" _, volume1Err := http.Get(verificationVolumeUrl) if volume1Err == nil { resStatu = true @@ -197,9 +201,11 @@ } case StartScriptAsMaVo: verificationMasterUrl := "http://" + ip + ":6333" - verificationVolumeUrl := "http://" + ip + ":6700" + verificationVolumeUrl := "http://" + ip + ":6700/ui/index.html" _, masterErr := http.Get(verificationMasterUrl) + fmt.Println("masterErr", masterErr) _, volume1Err := http.Get(verificationVolumeUrl) + fmt.Println("volume1Err", volume1Err) if masterErr == nil && volume1Err == nil { resStatu = true } -- Gitblit v1.8.0