Browse Source

Allow internal watches to use https and unix sockets

pull/2730/head
Kyle Havlovitz 8 years ago
parent
commit
9e23dabbfa
No known key found for this signature in database
GPG Key ID: 8A5E6B173056AD6C
  1. 15
      command/agent/command.go

15
command/agent/command.go

@ -1082,7 +1082,13 @@ func (c *Command) Run(args []string) int {
}
// Get the new client http listener addr
httpAddr, err := config.ClientListener(config.Addresses.HTTP, config.Ports.HTTP)
var httpAddr net.Addr
var err error
if config.Ports.HTTP != -1 {
httpAddr, err = config.ClientListener(config.Addresses.HTTP, config.Ports.HTTP)
} else {
httpAddr, err = config.ClientListener(config.Addresses.HTTPS, config.Ports.HTTPS)
}
if err != nil {
c.Ui.Error(fmt.Sprintf("Failed to determine HTTP address: %v", err))
}
@ -1092,7 +1098,12 @@ func (c *Command) Run(args []string) int {
go func(wp *watch.WatchPlan) {
wp.Handler = makeWatchHandler(logOutput, wp.Exempt["handler"])
wp.LogOutput = c.logOutput
if err := wp.Run(httpAddr.String()); err != nil {
addr := httpAddr.String()
// If it's a unix socket, prefix with unix:// so the client initializes correctly
if httpAddr.Network() == "unix" {
addr = "unix://" + addr
}
if err := wp.Run(addr); err != nil {
c.Ui.Error(fmt.Sprintf("Error running watch: %v", err))
}
}(wp)

Loading…
Cancel
Save