agent: Fixing issue with multiple watches. Fixes #337

This commit is contained in:
Armon Dadgar 2014-09-15 10:55:57 -07:00
parent 0cedc1fdce
commit 2067cc32dd
2 changed files with 11 additions and 4 deletions

View File

@ -1,3 +1,10 @@
## 0.4.1 (Unreleased)
BUG FIXES:
* Fixing only a single watch being run by an agent [GH-337]
* Fixing potential race in connection multiplexing
## 0.4.0 (September 5, 2014) ## 0.4.0 (September 5, 2014)
FEATURES: FEATURES:

View File

@ -464,13 +464,13 @@ func (c *Command) Run(args []string) int {
// Register the watches // Register the watches
for _, wp := range config.WatchPlans { for _, wp := range config.WatchPlans {
go func() { go func(wp *watch.WatchPlan) {
wp.Handler = makeWatchHandler(logOutput, wp.Exempt["handler"]) wp.Handler = makeWatchHandler(logOutput, wp.Exempt["handler"])
wp.LogOutput = c.logOutput wp.LogOutput = c.logOutput
if err := wp.Run(httpAddr); err != nil { if err := wp.Run(httpAddr); err != nil {
c.Ui.Error(fmt.Sprintf("Error running watch: %v", err)) c.Ui.Error(fmt.Sprintf("Error running watch: %v", err))
} }
}() }(wp)
} }
// Let the agent know we've finished registration // Let the agent know we've finished registration
@ -627,13 +627,13 @@ func (c *Command) handleReload(config *Config) *Config {
// Register the new watches // Register the new watches
for _, wp := range newConf.WatchPlans { for _, wp := range newConf.WatchPlans {
go func() { go func(wp *watch.WatchPlan) {
wp.Handler = makeWatchHandler(c.logOutput, wp.Exempt["handler"]) wp.Handler = makeWatchHandler(c.logOutput, wp.Exempt["handler"])
wp.LogOutput = c.logOutput wp.LogOutput = c.logOutput
if err := wp.Run(httpAddr); err != nil { if err := wp.Run(httpAddr); err != nil {
c.Ui.Error(fmt.Sprintf("Error running watch: %v", err)) c.Ui.Error(fmt.Sprintf("Error running watch: %v", err))
} }
}() }(wp)
} }
return newConf return newConf