Merge pull request #4185 from hashicorp/reload-fix
command/agent: don't re-parse the flags on reload
This commit is contained in:
commit
582f8d40dc
|
@ -61,7 +61,6 @@ type cmd struct {
|
||||||
versionPrerelease string
|
versionPrerelease string
|
||||||
versionHuman string
|
versionHuman string
|
||||||
shutdownCh <-chan struct{}
|
shutdownCh <-chan struct{}
|
||||||
args []string
|
|
||||||
flagArgs config.Flags
|
flagArgs config.Flags
|
||||||
logFilter *logutils.LevelFilter
|
logFilter *logutils.LevelFilter
|
||||||
logOutput io.Writer
|
logOutput io.Writer
|
||||||
|
@ -85,14 +84,6 @@ func (c *cmd) Run(args []string) int {
|
||||||
// readConfig is responsible for setup of our configuration using
|
// readConfig is responsible for setup of our configuration using
|
||||||
// the command line and any file configs
|
// the command line and any file configs
|
||||||
func (c *cmd) readConfig() *config.RuntimeConfig {
|
func (c *cmd) readConfig() *config.RuntimeConfig {
|
||||||
if err := c.flags.Parse(c.args); err != nil {
|
|
||||||
if !strings.Contains(err.Error(), "help requested") {
|
|
||||||
c.UI.Error(fmt.Sprintf("error parsing flags: %v", err))
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
c.flagArgs.Args = c.flags.Args()
|
|
||||||
|
|
||||||
b, err := config.NewBuilder(c.flagArgs)
|
b, err := config.NewBuilder(c.flagArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.UI.Error(err.Error())
|
c.UI.Error(err.Error())
|
||||||
|
@ -315,7 +306,13 @@ func startupTelemetry(conf *config.RuntimeConfig) (*metrics.InmemSink, error) {
|
||||||
|
|
||||||
func (c *cmd) run(args []string) int {
|
func (c *cmd) run(args []string) int {
|
||||||
// Parse our configs
|
// Parse our configs
|
||||||
c.args = args
|
if err := c.flags.Parse(args); err != nil {
|
||||||
|
if !strings.Contains(err.Error(), "help requested") {
|
||||||
|
c.UI.Error(fmt.Sprintf("error parsing flags: %v", err))
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
c.flagArgs.Args = c.flags.Args()
|
||||||
config := c.readConfig()
|
config := c.readConfig()
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return 1
|
return 1
|
||||||
|
@ -506,7 +503,7 @@ func (c *cmd) handleReload(agent *agent.Agent, cfg *config.RuntimeConfig) (*conf
|
||||||
"Failed to reload configs: %v", err))
|
"Failed to reload configs: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return cfg, errs
|
return newCfg, errs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmd) Synopsis() string {
|
func (c *cmd) Synopsis() string {
|
||||||
|
|
Loading…
Reference in New Issue