mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
main: remove duplicated self name check
This commit is contained in:
parent
f12583c163
commit
aa176610f3
@ -6,6 +6,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/coreos/etcd/pkg/types"
|
"github.com/coreos/etcd/pkg/types"
|
||||||
|
"github.com/coreos/etcd/raft"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServerConfig holds the configuration of etcd as taken from the command line or discovery.
|
// ServerConfig holds the configuration of etcd as taken from the command line or discovery.
|
||||||
@ -28,6 +29,9 @@ func (c *ServerConfig) Verify() error {
|
|||||||
if m == nil {
|
if m == nil {
|
||||||
return fmt.Errorf("could not find name %v in cluster", c.Name)
|
return fmt.Errorf("could not find name %v in cluster", c.Name)
|
||||||
}
|
}
|
||||||
|
if m.ID == raft.None {
|
||||||
|
return fmt.Errorf("cannot use None(%x) as member id", raft.None)
|
||||||
|
}
|
||||||
|
|
||||||
// No identical IPs in the cluster peer list
|
// No identical IPs in the cluster peer list
|
||||||
urlMap := make(map[string]bool)
|
urlMap := make(map[string]bool)
|
||||||
|
12
main.go
12
main.go
@ -14,7 +14,6 @@ import (
|
|||||||
flagtypes "github.com/coreos/etcd/pkg/flags"
|
flagtypes "github.com/coreos/etcd/pkg/flags"
|
||||||
"github.com/coreos/etcd/pkg/transport"
|
"github.com/coreos/etcd/pkg/transport"
|
||||||
"github.com/coreos/etcd/proxy"
|
"github.com/coreos/etcd/proxy"
|
||||||
"github.com/coreos/etcd/raft"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -124,17 +123,8 @@ func main() {
|
|||||||
|
|
||||||
// startEtcd launches the etcd server and HTTP handlers for client/server communication.
|
// startEtcd launches the etcd server and HTTP handlers for client/server communication.
|
||||||
func startEtcd() {
|
func startEtcd() {
|
||||||
self := cluster.FindName(*name)
|
|
||||||
if self == nil {
|
|
||||||
log.Fatalf("etcd: no member with name=%q exists", *name)
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.ID == raft.None {
|
|
||||||
log.Fatalf("etcd: cannot use None(%d) as member id", raft.None)
|
|
||||||
}
|
|
||||||
|
|
||||||
if *dir == "" {
|
if *dir == "" {
|
||||||
*dir = fmt.Sprintf("%v_etcd_data", self.Name)
|
*dir = fmt.Sprintf("%v_etcd_data", *name)
|
||||||
log.Printf("etcd: no data-dir provided, using default data-dir ./%s", *dir)
|
log.Printf("etcd: no data-dir provided, using default data-dir ./%s", *dir)
|
||||||
}
|
}
|
||||||
if err := os.MkdirAll(*dir, privateDirMode); err != nil {
|
if err := os.MkdirAll(*dir, privateDirMode); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user