Browse Source

main: fix temporary discovery cluster

Jonathan Boulle 11 years ago
parent
commit
5098cb0d32
1 changed files with 8 additions and 3 deletions
  1. 8 3
      main.go

+ 8 - 3
main.go

@@ -60,7 +60,10 @@ var (
 func init() {
 	flag.Var(cluster, "initial-cluster", "Initial cluster configuration for bootstrapping")
 	flag.Var(clusterState, "initial-cluster-state", "Initial cluster configuration for bootstrapping")
-	cluster.Set("default=http://localhost:2380,default=http://localhost:7001")
+	if err := cluster.Set("default=http://localhost:2380,default=http://localhost:7001"); err != nil {
+		// Should never happen
+		log.Panic(err)
+	}
 
 	flag.Var(flagtypes.NewURLsValue("http://localhost:2380,http://localhost:7001"), "advertise-peer-urls", "List of this member's peer URLs to advertise to the rest of the cluster")
 	flag.Var(flagtypes.NewURLsValue("http://localhost:2379,http://localhost:4001"), "advertise-client-urls", "List of this member's client URLs to advertise to the rest of the cluster")
@@ -261,9 +264,11 @@ func setClusterForDiscovery() error {
 		}
 		addrs := make([]string, len(apurls))
 		for i := range apurls {
-			addrs[i] = apurls[i].String()
+			addrs[i] = fmt.Sprintf("%s=%s", *name, apurls[i].String())
+		}
+		if err := cluster.Set(strings.Join(addrs, ",")); err != nil {
+			return err
 		}
-		cluster.Set(fmt.Sprintf("%s=%s", *name, strings.Join(addrs, ",")))
 	}
 	return nil
 }