|
|
|
@ -323,7 +323,39 @@ func (c *Command) handleReload(config *Config) *Config {
|
|
|
|
|
newConf.LogLevel = config.LogLevel |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: Update the services and checks
|
|
|
|
|
// Bulk update the services and checks
|
|
|
|
|
c.agent.PauseSync() |
|
|
|
|
defer c.agent.ResumeSync() |
|
|
|
|
|
|
|
|
|
// Deregister the old services
|
|
|
|
|
for _, service := range config.Services { |
|
|
|
|
ns := service.NodeService() |
|
|
|
|
c.agent.RemoveService(ns.ID) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Deregister the old checks
|
|
|
|
|
for _, check := range config.Checks { |
|
|
|
|
health := check.HealthCheck(config.NodeName) |
|
|
|
|
c.agent.RemoveCheck(health.CheckID) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Register the services
|
|
|
|
|
for _, service := range newConf.Services { |
|
|
|
|
ns := service.NodeService() |
|
|
|
|
chkType := service.CheckType() |
|
|
|
|
if err := c.agent.AddService(ns, chkType); err != nil { |
|
|
|
|
c.Ui.Error(fmt.Sprintf("Failed to register service '%s': %v", service.Name, err)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Register the checks
|
|
|
|
|
for _, check := range newConf.Checks { |
|
|
|
|
health := check.HealthCheck(config.NodeName) |
|
|
|
|
chkType := &check.CheckType |
|
|
|
|
if err := c.agent.AddCheck(health, chkType); err != nil { |
|
|
|
|
c.Ui.Error(fmt.Sprintf("Failed to register check '%s': %v %v", check.Name, err, check)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return newConf |
|
|
|
|
} |
|
|
|
|