agent: Switch to -data-dir, better error if missing. Fixes #2.

This commit is contained in:
Armon Dadgar 2014-02-22 17:34:57 -08:00
parent 49ba21a820
commit 13af774cb9
2 changed files with 9 additions and 3 deletions

View File

@ -51,7 +51,7 @@ func (c *Command) readConfig() *Config {
cmdFlags.StringVar(&cmdConfig.NodeName, "node", "", "node name") cmdFlags.StringVar(&cmdConfig.NodeName, "node", "", "node name")
cmdFlags.StringVar(&cmdConfig.RPCAddr, "rpc-addr", "", cmdFlags.StringVar(&cmdConfig.RPCAddr, "rpc-addr", "",
"address to bind RPC listener to") "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.Datacenter, "dc", "", "node datacenter")
cmdFlags.StringVar(&cmdConfig.DNSRecursor, "recursor", "", "address of dns recursor") cmdFlags.StringVar(&cmdConfig.DNSRecursor, "recursor", "", "address of dns recursor")
cmdFlags.StringVar(&cmdConfig.AdvertiseAddr, "advertise", "", "advertise address to use") 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 return config
} }

View File

@ -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 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). 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 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 This is especially critical for agents that are running in server mode, as they
must be able to persist the cluster state. 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. * `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. * `dns_addr` - Equivalent to the `-dns-addr` command-line flag.