diff --git a/cluster/agent.go b/cluster/agent.go index 89fae22..14e1ef5 100644 --- a/cluster/agent.go +++ b/cluster/agent.go @@ -272,6 +272,9 @@ func (a *Agent) raftPropose(msg *message.Message) { } func (a *Agent) getNodesFile() string { + if a.Config.NodesFileDir != "" { + return filepath.Join(a.Config.NodesFileDir, a.Config.NodeName+"-"+NodesFile) + } return a.Config.NodeName + "-" + NodesFile } diff --git a/cmd/cluster/main.go b/cmd/cluster/main.go index a34989c..c73c6ba 100644 --- a/cmd/cluster/main.go +++ b/cmd/cluster/main.go @@ -77,6 +77,7 @@ func realMain(ctx context.Context) error { flag.IntVar(&cfg.Redis.Options.DB, "redis-db", 0, "redis db for cluster mode") flag.BoolVar(&cfg.Log.Enable, "log-enable", true, "log enabled or not") flag.StringVar(&cfg.Log.Filename, "log-file", "./logs/comqtt.log", "log filename") + flag.StringVar(&cfg.Cluster.NodesFileDir, "nodes-file-dir", "", "directory holds nodes.json assisting node discovery for cluster") //parse arguments flag.Parse() //load config file diff --git a/config/config.go b/config/config.go index 5fe93f4..7a393f7 100644 --- a/config/config.go +++ b/config/config.go @@ -146,6 +146,7 @@ type Cluster struct { InboundPoolSize int `yaml:"inbound-pool-size" json:"inbound-pool-size"` OutboundPoolSize int `yaml:"outbound-pool-size" json:"outbound-pool-size"` InoutPoolNonblocking bool `yaml:"inout-pool-nonblocking" json:"inout-pool-nonblocking"` + NodesFileDir string `yaml:"nodes-file-dir" json:"nodes-file-dir"` } func GenTlsConfig(conf *Config) (*tls2.Config, error) {