diff --git a/cluster/config.go b/cluster/config.go index 66eedff..3aad6d0 100644 --- a/cluster/config.go +++ b/cluster/config.go @@ -2,6 +2,7 @@ package cluster import ( "encoding/json" + "errors" "fmt" "io/ioutil" ) @@ -69,6 +70,10 @@ func ReadCfg(path string, nodeid int) (*ClusterConfig, error) { } } + if c.currentNode.NodeID == 0 { + return nil, errors.New(fmt.Sprintf("Cannot find NodeId %d in cluster.json!", nodeid)) + } + //3.存入当前Node服务名 c.mapClusterNodeService[c.currentNode.NodeName] = append(c.mapClusterNodeService[c.currentNode.NodeName], c.currentNode)