diff options
Diffstat (limited to 'weed/command/master.go')
| -rw-r--r-- | weed/command/master.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/weed/command/master.go b/weed/command/master.go index fb09a24b4..3d33f4f7a 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -100,8 +100,11 @@ func runMaster(cmd *Command, args []string) bool { } func startMaster(masterOption MasterOptions, masterWhiteList []string) { + + myMasterAddress, peers := checkPeers(*masterOption.ip, *masterOption.port, *masterOption.peers) + r := mux.NewRouter() - ms := weed_server.NewMasterServer(r, masterOption.toMasterOption(masterWhiteList)) + ms := weed_server.NewMasterServer(r, masterOption.toMasterOption(masterWhiteList), peers) listeningAddress := *masterOption.ipBind + ":" + strconv.Itoa(*masterOption.port) glog.V(0).Infof("Start Seaweed Master %s at %s", util.VERSION, listeningAddress) masterListener, e := util.NewListener(listeningAddress, 0) @@ -109,7 +112,6 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { glog.Fatalf("Master startup error: %v", e) } // start raftServer - myMasterAddress, peers := checkPeers(*masterOption.ip, *masterOption.port, *masterOption.peers) raftServer := weed_server.NewRaftServer(security.LoadClientTLS(viper.Sub("grpc"), "master"), peers, myMasterAddress, *masterOption.metaFolder, ms.Topo, *masterOption.pulseSeconds) if raftServer == nil { @@ -131,6 +133,8 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) { glog.V(0).Infof("Start Seaweed Master %s grpc server at %s:%d", util.VERSION, *masterOption.ipBind, grpcPort) go grpcS.Serve(grpcL) + go ms.MasterClient.KeepConnectedToMaster() + // start http server httpS := &http.Server{Handler: r} go httpS.Serve(masterListener) @@ -152,11 +156,10 @@ func checkPeers(masterIp string, masterPort int, peers string) (masterAddress st } } - peerCount := len(cleanedPeers) if !hasSelf { - peerCount += 1 + cleanedPeers = append(cleanedPeers, masterAddress) } - if peerCount%2 == 0 { + if len(cleanedPeers)%2 == 0 { glog.Fatalf("Only odd number of masters are supported!") } return |
