From 32aba6aa23e78886ddca2743f760ff6de22f4b50 Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期一, 13 四月 2020 10:46:04 +0800 Subject: [PATCH] perfect asVolume somethings --- controllers/swfsControllers.go | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diff --git a/controllers/swfsControllers.go b/controllers/swfsControllers.go index 3e770e3..18d0eb9 100644 --- a/controllers/swfsControllers.go +++ b/controllers/swfsControllers.go @@ -53,9 +53,14 @@ util.ResponseFormat(c, code.AddSuccess, "鍔犲叆鑺傜偣鎴愬姛") return } else if role == "volume" { - AsVolume() - util.ResponseFormat(c, code.AddSuccess, "鍔犲叆鑺傜偣鎴愬姛") - return + status := AsVolume() + if status == true { + util.ResponseFormat(c, code.AddSuccess, "鍔犲叆鑺傜偣鎴愬姛") + return + } else { + util.ResponseFormat(c, code.AddClusterInfoErr, "褰撳墠杩樻病鏈変富鑺傜偣") + return + } } else { util.ResponseFormat(c, code.RequestParamError, "閫夋嫨鑺傜偣绫诲瀷閿欒") return @@ -170,17 +175,23 @@ } //浣滀负鏁版嵁鑺傜偣鍔犲叆 -func AsVolume() { +func AsVolume() bool { + nowPeers := GetNowPeersList() + if nowPeers == nil || len(nowPeers) == 0 { + return false + } UpdatePeers(config.Server.ScriptPath, StartServerScript, GetNewPeers(), GetNewPeers()) ReplaceLineContentBySearch(StartScriptAsVolume, config.Server.ScriptPath, StartServerScript) ReplaceLineContentBySearch("peers=", config.Server.ScriptPath, StartServerScript) StartServer(config.Server.ScriptPath) + return true } //浣滀负涓昏妭鐐瑰姞鍏ワ紙榛樿鍖呭惈鏁版嵁鑺傜偣锛� -func AsMaster() { +func AsMaster() bool { nowPeers := GetNowPeersList() RequestMasterNodesOperation(nowPeers) + return true } //鑾峰彇褰撳墠闆嗙兢鍒楄〃 -- Gitblit v1.8.0