|
|
@ -646,14 +646,19 @@ func (a *Agent) reloadWatches(cfg *config.RuntimeConfig) error { |
|
|
|
|
|
|
|
|
|
|
|
// Determine the primary http(s) endpoint.
|
|
|
|
// Determine the primary http(s) endpoint.
|
|
|
|
var netaddr net.Addr |
|
|
|
var netaddr net.Addr |
|
|
|
|
|
|
|
https := false |
|
|
|
if len(cfg.HTTPAddrs) > 0 { |
|
|
|
if len(cfg.HTTPAddrs) > 0 { |
|
|
|
netaddr = cfg.HTTPAddrs[0] |
|
|
|
netaddr = cfg.HTTPAddrs[0] |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
netaddr = cfg.HTTPSAddrs[0] |
|
|
|
netaddr = cfg.HTTPSAddrs[0] |
|
|
|
|
|
|
|
https = true |
|
|
|
} |
|
|
|
} |
|
|
|
addr := netaddr.String() |
|
|
|
addr := netaddr.String() |
|
|
|
if netaddr.Network() == "unix" { |
|
|
|
if netaddr.Network() == "unix" { |
|
|
|
addr = "unix://" + addr |
|
|
|
addr = "unix://" + addr |
|
|
|
|
|
|
|
https = false |
|
|
|
|
|
|
|
} else if https { |
|
|
|
|
|
|
|
addr = "https://" + addr |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Fire off a goroutine for each new watch plan.
|
|
|
|
// Fire off a goroutine for each new watch plan.
|
|
|
@ -669,7 +674,19 @@ func (a *Agent) reloadWatches(cfg *config.RuntimeConfig) error { |
|
|
|
wp.Handler = makeHTTPWatchHandler(a.LogOutput, httpConfig) |
|
|
|
wp.Handler = makeHTTPWatchHandler(a.LogOutput, httpConfig) |
|
|
|
} |
|
|
|
} |
|
|
|
wp.LogOutput = a.LogOutput |
|
|
|
wp.LogOutput = a.LogOutput |
|
|
|
if err := wp.Run(addr); err != nil { |
|
|
|
|
|
|
|
|
|
|
|
config := api.DefaultConfig() |
|
|
|
|
|
|
|
if https { |
|
|
|
|
|
|
|
if a.config.CAPath != "" { |
|
|
|
|
|
|
|
config.TLSConfig.CAPath = a.config.CAPath |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if a.config.CAFile != "" { |
|
|
|
|
|
|
|
config.TLSConfig.CAFile = a.config.CAFile |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
config.TLSConfig.Address = addr |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := wp.Run(addr, config); err != nil { |
|
|
|
a.logger.Printf("[ERR] agent: Failed to run watch: %v", err) |
|
|
|
a.logger.Printf("[ERR] agent: Failed to run watch: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
}(wp) |
|
|
|
}(wp) |
|
|
|