From 13af774cb91196ed5a5a7bbb085ce5b593bcd9fb Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Sat, 22 Feb 2014 17:34:57 -0800 Subject: [PATCH] agent: Switch to -data-dir, better error if missing. Fixes #2. --- command/agent/command.go | 8 +++++++- website/source/docs/agent/options.html.markdown | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/command/agent/command.go b/command/agent/command.go index 836538d4a4..31595cd93a 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -51,7 +51,7 @@ func (c *Command) readConfig() *Config { cmdFlags.StringVar(&cmdConfig.NodeName, "node", "", "node name") cmdFlags.StringVar(&cmdConfig.RPCAddr, "rpc-addr", "", "address to bind RPC listener to") - cmdFlags.StringVar(&cmdConfig.DataDir, "data", "", "path to the data directory") + cmdFlags.StringVar(&cmdConfig.DataDir, "data-dir", "", "path to the data directory") cmdFlags.StringVar(&cmdConfig.Datacenter, "dc", "", "node datacenter") cmdFlags.StringVar(&cmdConfig.DNSRecursor, "recursor", "", "address of dns recursor") cmdFlags.StringVar(&cmdConfig.AdvertiseAddr, "advertise", "", "advertise address to use") @@ -93,6 +93,12 @@ func (c *Command) readConfig() *Config { } } + // Ensure we have a data directory + if config.DataDir == "" { + c.Ui.Error("Must specify data directory using -data-dir") + return nil + } + return config } diff --git a/website/source/docs/agent/options.html.markdown b/website/source/docs/agent/options.html.markdown index 2c436dcd5c..654219007f 100644 --- a/website/source/docs/agent/options.html.markdown +++ b/website/source/docs/agent/options.html.markdown @@ -78,7 +78,7 @@ The options below are all specified on the command-line. in order to query a running Consul agent. It is also used by other applications to control Consul using it's [RPC protocol](/docs/agent/rpc.html). -* `-data` - This flag provides a data directory for the agent to store state. +* `-data-dir` - This flag provides a data directory for the agent to store state. This is required for all agents. The directory should be durable across reboots. This is especially critical for agents that are running in server mode, as they must be able to persist the cluster state. @@ -152,7 +152,7 @@ They are documented seperately under [check configuration](/docs/agent/checks.ht * `datacenter` - Equivalent to the `-dc` command-line flag. -* `data_dir` - Equivalent to the `-data` command-line flag. +* `data_dir` - Equivalent to the `-data-dir` command-line flag. * `dns_addr` - Equivalent to the `-dns-addr` command-line flag.