mirror of https://github.com/status-im/consul.git
agent: only ignore errors on IsNotExist()
This commit is contained in:
parent
4675cdf01c
commit
bf48651c58
|
@ -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
|
||||
// is necessary to avoid situations where Consul cannot start if the
|
||||
// socket file exists in case of unexpected termination.
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
if err := os.Remove(path); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,10 +61,8 @@ func NewHTTPServers(agent *Agent, config *Config, logOutput io.Writer) ([]*HTTPS
|
|||
|
||||
if path, ok := unixSocketAddr(config.Addresses.HTTPS); ok {
|
||||
// See command/agent/config.go
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
if err := os.Remove(path); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := os.Remove(path); err != nil && !os.IsNotExist(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 {
|
||||
// See command/agent/config.go
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
if err := os.Remove(path); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -240,16 +240,17 @@ definitions support being updated during a reload.
|
|||
up to the TTL value.
|
||||
|
||||
* `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:
|
||||
unix://[/path/to/socket];[username|uid];[gid];[mode]. The socket will be created
|
||||
in the specified location with the given username or uid, gid, and mode. The
|
||||
user Consul is running as must have appropriate permissions to change the socket
|
||||
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
|
||||
the path to the socket, e.g. "unix://path/to/socket". You can also place the desired
|
||||
values in `CONSUL_RPC_ADDR` and `CONSUL_HTTP_ADDR` environment variables. For TCP
|
||||
addresses, these should be in the form ip:port.
|
||||
The following keys are valid:
|
||||
and `http`, a Unix socket can be specified in the following form
|
||||
`unix:///path/to/socket`. A new domain socket will be created at the given
|
||||
path. Any existing socket file (or any other kind of file) at the specified
|
||||
path will be **overwritten**, so use caution when configuring this argument.
|
||||
|
||||
When running Consul agent commands against Unix socket interfaces, use the
|
||||
`-rpc-addr` or `-http-addr` arguments to specify the path to the socket. You
|
||||
can also place the desired values in `CONSUL_RPC_ADDR` and `CONSUL_HTTP_ADDR`
|
||||
environment variables. For TCP addresses, these should be in the form ip:port.
|
||||
|
||||
The following keys are valid:
|
||||
* `dns` - The DNS server. Defaults to `client_addr`
|
||||
* `http` - The HTTP API. Defaults to `client_addr`
|
||||
* `rpc` - The RPC endpoint. Defaults to `client_addr`
|
||||
|
|
Loading…
Reference in New Issue