Merge pull request #84 from sgotti/executor_listen_wildcard

executor: listen on wildcard address
This commit is contained in:
Simone Gotti 2019-08-06 15:18:46 +02:00 committed by GitHub
commit 252bd95a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -1308,6 +1308,7 @@ type Executor struct {
id string id string
runningTasks *runningTasks runningTasks *runningTasks
driver driver.Driver driver driver.Driver
listenAddress string
listenURL string listenURL string
dynamic bool dynamic bool
} }
@ -1348,6 +1349,8 @@ func NewExecutor(c *config.Executor) (*Executor, error) {
e.id = id e.id = id
// TODO(sgotti) now the first available private ip will be used and the executor will bind to the wildcard address
// improve this to let the user define the bind and the advertize address
addr, err := sockaddr.GetPrivateIP() addr, err := sockaddr.GetPrivateIP()
if err != nil { if err != nil {
return nil, errors.Errorf("cannot discover executor listen address: %w", err) return nil, errors.Errorf("cannot discover executor listen address: %w", err)
@ -1366,6 +1369,8 @@ func NewExecutor(c *config.Executor) (*Executor, error) {
u.Host = net.JoinHostPort(addr, port) u.Host = net.JoinHostPort(addr, port)
e.listenURL = u.String() e.listenURL = u.String()
e.listenAddress = fmt.Sprintf(":%s", port)
var d driver.Driver var d driver.Driver
switch c.Driver.Type { switch c.Driver.Type {
case config.DriverTypeDocker: case config.DriverTypeDocker:
@ -1413,7 +1418,7 @@ func (e *Executor) Run(ctx context.Context) error {
go e.handleTasks(ctx, ch) go e.handleTasks(ctx, ch)
httpServer := http.Server{ httpServer := http.Server{
Addr: e.c.Web.ListenAddress, Addr: e.listenAddress,
Handler: apirouter, Handler: apirouter,
} }
lerrCh := make(chan error) lerrCh := make(chan error)