|
|
@@ -52,24 +52,18 @@ func main() {
|
|
|
profile(config.CPUProfileFile)
|
|
|
}
|
|
|
|
|
|
- // Load info object.
|
|
|
- info, err := config.Info()
|
|
|
- if err != nil {
|
|
|
- log.Fatal("info:", err)
|
|
|
+ // Only guess the machine name if there is no data dir specified
|
|
|
+ // because the info file will should have our name
|
|
|
+ if config.Name == "" && config.DataDir == "" {
|
|
|
+ config.NameFromHostname()
|
|
|
}
|
|
|
- if info.Name == "" {
|
|
|
- host, err := os.Hostname()
|
|
|
- if err != nil || host == "" {
|
|
|
- log.Fatal("Node name required and hostname not set. e.g. '-name=name'")
|
|
|
- }
|
|
|
- log.Warnf("Using hostname %s as the node name. You must ensure this name is unique among etcd nodes.", host)
|
|
|
- info.Name = host
|
|
|
+
|
|
|
+ if config.DataDir == "" && config.Name != "" {
|
|
|
+ config.DataDirFromName()
|
|
|
}
|
|
|
|
|
|
- // Setup a default directory based on the node name
|
|
|
if config.DataDir == "" {
|
|
|
- config.DataDir = info.Name + ".etcd"
|
|
|
- log.Warnf("Using the directory %s as the etcd configuration directory because a directory was not specified. ", config.DataDir)
|
|
|
+ log.Fatal("The data dir was not set and could not be guessed from machine name")
|
|
|
}
|
|
|
|
|
|
// Create data directory if it doesn't already exist.
|
|
|
@@ -77,6 +71,12 @@ func main() {
|
|
|
log.Fatalf("Unable to create path: %s", err)
|
|
|
}
|
|
|
|
|
|
+ // Load info object.
|
|
|
+ info, err := config.Info()
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("info:", err)
|
|
|
+ }
|
|
|
+
|
|
|
// Retrieve TLS configuration.
|
|
|
tlsConfig, err := info.EtcdTLS.Config()
|
|
|
if err != nil {
|