mirror of https://github.com/hashicorp/consul
parent
1d5b56eec1
commit
c47db2c922
|
@ -466,7 +466,7 @@ func (c *Command) setupAgent(config *Config, logOutput io.Writer, logWriter *log
|
||||||
c.agent = agent
|
c.agent = agent
|
||||||
|
|
||||||
if config.Ports.HTTP > 0 || config.Ports.HTTPS > 0 {
|
if config.Ports.HTTP > 0 || config.Ports.HTTPS > 0 {
|
||||||
servers, err := NewHTTPServers(agent, config, logOutput)
|
servers, err := NewHTTPServers(agent, logOutput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
agent.Shutdown()
|
agent.Shutdown()
|
||||||
c.UI.Error(fmt.Sprintf("Error starting http servers: %s", err))
|
c.UI.Error(fmt.Sprintf("Error starting http servers: %s", err))
|
||||||
|
|
|
@ -34,11 +34,13 @@ type HTTPServer struct {
|
||||||
|
|
||||||
// NewHTTPServers starts new HTTP servers to provide an interface to
|
// NewHTTPServers starts new HTTP servers to provide an interface to
|
||||||
// the agent.
|
// the agent.
|
||||||
func NewHTTPServers(agent *Agent, config *Config, logOutput io.Writer) ([]*HTTPServer, error) {
|
func NewHTTPServers(agent *Agent, logOutput io.Writer) ([]*HTTPServer, error) {
|
||||||
if logOutput == nil {
|
if logOutput == nil {
|
||||||
return nil, fmt.Errorf("Please provide a valid logOutput(io.Writer)")
|
return nil, fmt.Errorf("Please provide a valid logOutput(io.Writer)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config := agent.config
|
||||||
|
|
||||||
var servers []*HTTPServer
|
var servers []*HTTPServer
|
||||||
|
|
||||||
if config.Ports.HTTPS > 0 {
|
if config.Ports.HTTPS > 0 {
|
||||||
|
|
|
@ -60,7 +60,7 @@ RECONF:
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, agent := makeAgentLog(t, conf, l, logWriter)
|
dir, agent := makeAgentLog(t, conf, l, logWriter)
|
||||||
servers, err := NewHTTPServers(agent, conf, agent.logOutput)
|
servers, err := NewHTTPServers(agent, agent.logOutput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if configTry < 3 {
|
if configTry < 3 {
|
||||||
goto RECONF
|
goto RECONF
|
||||||
|
@ -160,7 +160,7 @@ func TestHTTPServer_UnixSocket_FileExists(t *testing.T) {
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
// Try to start the server with the same path anyways.
|
// Try to start the server with the same path anyways.
|
||||||
if _, err := NewHTTPServers(agent, conf, agent.logOutput); err != nil {
|
if _, err := NewHTTPServers(agent, agent.logOutput); err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ func testAgentWithConfigReload(t *testing.T, cb func(c *agent.Config), reloadCh
|
||||||
|
|
||||||
conf.Addresses.HTTP = "127.0.0.1"
|
conf.Addresses.HTTP = "127.0.0.1"
|
||||||
httpAddr := fmt.Sprintf("127.0.0.1:%d", conf.Ports.HTTP)
|
httpAddr := fmt.Sprintf("127.0.0.1:%d", conf.Ports.HTTP)
|
||||||
http, err := agent.NewHTTPServers(a, conf, os.Stderr)
|
http, err := agent.NewHTTPServers(a, os.Stderr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.RemoveAll(dir)
|
os.RemoveAll(dir)
|
||||||
t.Fatalf(fmt.Sprintf("err: %v", err))
|
t.Fatalf(fmt.Sprintf("err: %v", err))
|
||||||
|
|
Loading…
Reference in New Issue