From c10653ae0cf430633ee839be9e20c66a2dbd2a8d Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Thu, 31 Oct 2013 15:16:28 -0700 Subject: [PATCH] feat(etcd): use hostname as machine name by default I don't want etcd to require parameters so people can rapidly try it out. Try to use the hostname as the name instead. --- etcd.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/etcd.go b/etcd.go index 3c01356f1..c7a92042b 100644 --- a/etcd.go +++ b/etcd.go @@ -42,7 +42,12 @@ func main() { log.Fatal("info:", err) } if info.Name == "" { - log.Fatal("ERROR: server name required. e.g. '-n=server_name'") + host, err := os.Hostname() + if err != nil || host == "" { + log.Fatal("Machine name required and hostname not set. e.g. '-n=machine_name'") + } + log.Warnf("Using hostname %s as the machine name. You must ensure this name is unique among etcd machines.", host) + info.Name = host } // Retrieve TLS configuration.