Browse Source

revert duplicated code

pull/7419/head
chrislu 2 months ago
parent
commit
7494593630
  1. 18
      weed/command/server.go

18
weed/command/server.go

@ -235,26 +235,12 @@ func runServer(cmd *Command, args []string) bool {
var actualPeersForComponents string var actualPeersForComponents string
if *isStartingMasterServer { if *isStartingMasterServer {
// Determine master addresses for other components // Determine master addresses for other components
// checkPeers will be called later in startMaster for validation
if isSingleMasterMode(*masterOptions.peers) || *masterOptions.peers == "" { if isSingleMasterMode(*masterOptions.peers) || *masterOptions.peers == "" {
// Single-master mode or no peers: use current server address // Single-master mode or no peers: use current server address
actualPeersForComponents = util.JoinHostPort(*serverIp, *masterOptions.port) actualPeersForComponents = util.JoinHostPort(*serverIp, *masterOptions.port)
} else { } else {
// Multi-master mode: parse and potentially add self to peer list
peerList := pb.ServerAddresses(*masterOptions.peers).ToAddresses()
myAddress := pb.NewServerAddress(*serverIp, *masterOptions.port, *masterOptions.portGrpc)
// Check if current server is in the list
hasSelf := false
for _, peer := range peerList {
if peer.ToHttpAddress() == myAddress.ToHttpAddress() {
hasSelf = true
break
}
}
if !hasSelf {
peerList = append(peerList, myAddress)
}
actualPeersForComponents = strings.Join(pb.ToAddressStrings(peerList), ",")
// Multi-master mode: use the provided peers (checkPeers in startMaster will validate)
actualPeersForComponents = *masterOptions.peers
} }
} else if *masterOptions.peers != "" { } else if *masterOptions.peers != "" {
// If not starting a master, just use the provided peers // If not starting a master, just use the provided peers

Loading…
Cancel
Save