1package reload 2 3import ( 4 "flag" 5 "fmt" 6 7 "github.com/hashicorp/consul/command/flags" 8 "github.com/mitchellh/cli" 9) 10 11func New(ui cli.Ui) *cmd { 12 c := &cmd{UI: ui} 13 c.init() 14 return c 15} 16 17type cmd struct { 18 UI cli.Ui 19 flags *flag.FlagSet 20 http *flags.HTTPFlags 21 help string 22} 23 24func (c *cmd) init() { 25 c.flags = flag.NewFlagSet("", flag.ContinueOnError) 26 c.http = &flags.HTTPFlags{} 27 flags.Merge(c.flags, c.http.ClientFlags()) 28 c.help = flags.Usage(help, c.flags) 29} 30 31func (c *cmd) Run(args []string) int { 32 if err := c.flags.Parse(args); err != nil { 33 return 1 34 } 35 36 client, err := c.http.APIClient() 37 if err != nil { 38 c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err)) 39 return 1 40 } 41 42 if err := client.Agent().Reload(); err != nil { 43 c.UI.Error(fmt.Sprintf("Error reloading: %s", err)) 44 return 1 45 } 46 47 c.UI.Output("Configuration reload triggered") 48 return 0 49} 50 51func (c *cmd) Synopsis() string { 52 return synopsis 53} 54 55func (c *cmd) Help() string { 56 return c.help 57} 58 59const synopsis = "Triggers the agent to reload configuration files" 60const help = ` 61Usage: consul reload 62 63 Causes the agent to reload configurations. This can be used instead 64 of sending the SIGHUP signal to the agent. 65` 66