From aff951ca4e170c32eb05fc54de9f8b5d16b69c23 Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Fri, 10 Jun 2016 11:19:02 -0400 Subject: [PATCH] Always create a consul.Syncer. Use a default Consul Config if necessary. --- client/driver/executor/executor.go | 7 +++++++ command/agent/consul/syncer.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/client/driver/executor/executor.go b/client/driver/executor/executor.go index b238aa2bc..5f9d7d73d 100644 --- a/client/driver/executor/executor.go +++ b/client/driver/executor/executor.go @@ -205,7 +205,14 @@ type UniversalExecutor struct { // NewExecutor returns an Executor func NewExecutor(logger *log.Logger) Executor { + shutdownCh := make(chan struct{}) + cs, err := consul.NewSyncer(nil, shutdownCh, logger) + if err != nil { + return err + } + exec := &UniversalExecutor{ + consulSyncer: cs, logger: logger, processExited: make(chan interface{}), shutdownCh: make(chan struct{}), diff --git a/command/agent/consul/syncer.go b/command/agent/consul/syncer.go index 0c06091d0..255f4c6ad 100644 --- a/command/agent/consul/syncer.go +++ b/command/agent/consul/syncer.go @@ -111,7 +111,14 @@ type Syncer struct { func NewSyncer(config *config.ConsulConfig, shutdownCh chan struct{}, logger *log.Logger) (*Syncer, error) { var err error var c *consul.Client + cfg := consul.DefaultConfig() + + // If a nil config was provided, fall back to the default config + if config == nil { + config = cfg + } + if config.Addr != "" { cfg.Address = config.Addr }