| | |
| | | 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 |
| | |
| | | } |
| | | |
| | | //作为数据节点加入 |
| | | 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 |
| | | } |
| | | |
| | | //获取当前集群列表 |