agent: only ignore errors on IsNotExist()

pull/612/head
Ryan Uber 2015-01-16 09:14:52 -08:00
parent 4675cdf01c
commit bf48651c58
3 changed files with 17 additions and 22 deletions

View File

@ -299,10 +299,8 @@ func (c *Command) setupAgent(config *Config, logOutput io.Writer, logWriter *log
// Remove the socket if it exists, or we'll get a bind error. This // Remove the socket if it exists, or we'll get a bind error. This
// is necessary to avoid situations where Consul cannot start if the // is necessary to avoid situations where Consul cannot start if the
// socket file exists in case of unexpected termination. // socket file exists in case of unexpected termination.
if _, err := os.Stat(path); err == nil { if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
if err := os.Remove(path); err != nil { return err
return err
}
} }
} }

View File

@ -61,10 +61,8 @@ func NewHTTPServers(agent *Agent, config *Config, logOutput io.Writer) ([]*HTTPS
if path, ok := unixSocketAddr(config.Addresses.HTTPS); ok { if path, ok := unixSocketAddr(config.Addresses.HTTPS); ok {
// See command/agent/config.go // See command/agent/config.go
if _, err := os.Stat(path); err == nil { if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
if err := os.Remove(path); err != nil { return nil, err
return nil, err
}
} }
} }
@ -106,10 +104,8 @@ func NewHTTPServers(agent *Agent, config *Config, logOutput io.Writer) ([]*HTTPS
if path, ok := unixSocketAddr(config.Addresses.HTTP); ok { if path, ok := unixSocketAddr(config.Addresses.HTTP); ok {
// See command/agent/config.go // See command/agent/config.go
if _, err := os.Stat(path); err == nil { if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
if err := os.Remove(path); err != nil { return nil, err
return nil, err
}
} }
} }

View File

@ -240,16 +240,17 @@ definitions support being updated during a reload.
up to the TTL value. up to the TTL value.
* `addresses` - This is a nested object that allows setting bind addresses. For `rpc` * `addresses` - This is a nested object that allows setting bind addresses. For `rpc`
and `http`, a Unix socket can be specified in the following form: and `http`, a Unix socket can be specified in the following form
unix://[/path/to/socket];[username|uid];[gid];[mode]. The socket will be created `unix:///path/to/socket`. A new domain socket will be created at the given
in the specified location with the given username or uid, gid, and mode. The path. Any existing socket file (or any other kind of file) at the specified
user Consul is running as must have appropriate permissions to change the socket path will be **overwritten**, so use caution when configuring this argument.
ownership to the given uid or gid. When running Consul agent commands against
Unix socket interfaces, use the `-rpc-addr` or `-http-addr` arguments to specify When running Consul agent commands against Unix socket interfaces, use the
the path to the socket, e.g. "unix://path/to/socket". You can also place the desired `-rpc-addr` or `-http-addr` arguments to specify the path to the socket. You
values in `CONSUL_RPC_ADDR` and `CONSUL_HTTP_ADDR` environment variables. For TCP can also place the desired values in `CONSUL_RPC_ADDR` and `CONSUL_HTTP_ADDR`
addresses, these should be in the form ip:port. environment variables. For TCP addresses, these should be in the form ip:port.
The following keys are valid:
The following keys are valid:
* `dns` - The DNS server. Defaults to `client_addr` * `dns` - The DNS server. Defaults to `client_addr`
* `http` - The HTTP API. Defaults to `client_addr` * `http` - The HTTP API. Defaults to `client_addr`
* `rpc` - The RPC endpoint. Defaults to `client_addr` * `rpc` - The RPC endpoint. Defaults to `client_addr`