Skip to content

Commit

Permalink
Merge pull request #607 from mattbostock/prevent_panic
Browse files Browse the repository at this point in the history
Prevent panic on failed config load
  • Loading branch information
fabxc committed Jan 17, 2017
2 parents f2ba86e + 890f148 commit b5af749
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (api *API) Register(r *route.Router) {
}

// Update sets the configuration string to a new value.
func (api *API) Update(cfg string, resolveTimeout time.Duration) {
func (api *API) Update(cfg string, resolveTimeout time.Duration) error {
api.mtx.Lock()
defer api.mtx.Unlock()

Expand All @@ -137,8 +137,11 @@ func (api *API) Update(cfg string, resolveTimeout time.Duration) {
configJSON, err := config.Load(cfg)
if err != nil {
log.Errorf("error: %v", err)
return err
}

api.configJSON = *configJSON
return nil
}

type errorType string
Expand Down
5 changes: 4 additions & 1 deletion cmd/alertmanager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ func main() {
return err
}

apiv.Update(conf.String(), time.Duration(conf.Global.ResolveTimeout))
err = apiv.Update(conf.String(), time.Duration(conf.Global.ResolveTimeout))
if err != nil {
return err
}

tmpl, err = template.FromGlobs(conf.Templates...)
if err != nil {
Expand Down

0 comments on commit b5af749

Please sign in to comment.