From e27aa3e21d35830dfac42edf1ba9ab09f563eda9 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Fri, 7 Feb 2014 12:03:14 -0800 Subject: [PATCH] agent: Adding some primitive config reloading --- command/agent/command.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/command/agent/command.go b/command/agent/command.go index ac8409a03f..9052c8a92b 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -304,8 +304,28 @@ WAIT: // handleReload is invoked when we should reload our configs, e.g. SIGHUP func (c *Command) handleReload(config *Config) *Config { c.Ui.Output("Reloading configuration...") - // TODO : handle reload - return config + newConf := c.readConfig() + if newConf == nil { + c.Ui.Error(fmt.Sprintf("Failed to reload configs")) + return config + } + + // Change the log level + minLevel := logutils.LogLevel(strings.ToUpper(newConf.LogLevel)) + if ValidateLevelFilter(minLevel, c.logFilter) { + c.logFilter.SetMinLevel(minLevel) + } else { + c.Ui.Error(fmt.Sprintf( + "Invalid log level: %s. Valid log levels are: %v", + minLevel, c.logFilter.Levels)) + + // Keep the current log level + newConf.LogLevel = config.LogLevel + } + + // TODO: Update the services and checks + + return newConf } func (c *Command) Synopsis() string {