Initialize the config copy after client init

This commit is contained in:
Alex Dadgar 2016-02-10 19:01:57 -08:00
parent 4d7ed4f164
commit 0e68c7c949

View file

@ -113,7 +113,6 @@ func NewClient(cfg *config.Config) (*Client, error) {
// Create the client
c := &Client{
config: cfg,
configCopy: cfg.Copy(),
start: time.Now(),
connPool: nomad.NewPool(cfg.LogOutput, clientRPCCache, clientMaxStreams, nil),
logger: logger,
@ -149,6 +148,10 @@ func NewClient(cfg *config.Config) (*Client, error) {
// Set up the known servers list
c.SetServers(c.config.Servers)
// Store the config copy before restoring state but after it has been
// initialized.
c.configCopy = c.config.Copy()
// Restore the state
if err := c.restoreState(); err != nil {
return nil, fmt.Errorf("failed to restore state: %v", err)