By default use Raft network address as node ID
@@ -198,15 +198,11 @@ func main() {
}
dbConf := store.NewDBConfig(dsn, !onDisk)
- nid, err := idOrHostname()
- if err != nil {
- log.Fatalf("failed to determine node ID: %s", err.Error())
- }
str := store.New(&store.StoreConfig{
DBConf: dbConf,
Dir: dataPath,
Tn: raftTn,
- ID: nid,
+ ID: idOrRaftAddr(),
})
// Set optional parameters on store.
@@ -278,7 +274,7 @@ func main() {
}
}
- if j, err := cluster.Join(joins, nid, advAddr, &tlsConfig); err != nil {
+ if j, err := cluster.Join(joins, str.ID(), advAddr, &tlsConfig); err != nil {
log.Fatalf("failed to join cluster at %s: %s", joins, err.Error())
} else {
log.Println("successfully joined cluster at", j)
@@ -415,11 +411,14 @@ func credentialStore() (*auth.CredentialsStore, error) {
return cs, nil
}
-func idOrHostname() (string, error) {
+func idOrRaftAddr() string {
if nodeID != "" {
- return nodeID, nil
+ return nodeID
+ }
+ if raftAdv == "" {
+ return raftAddr
}
- return os.Hostname()
+ return raftAdv
}
// prof stores the file locations of active profiles.
