Created
February 26, 2018 03:30
-
-
Save tanan/e43440ff5859119007da245a99a4e5f5 to your computer and use it in GitHub Desktop.
reload config file (prometheus.yml)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func reloadConfig(filename string, logger log.Logger, rls ...func(*config.Config) error) (err error) { | |
level.Info(logger).Log("msg", "Loading configuration file", "filename", filename) | |
defer func() { | |
if err == nil { | |
configSuccess.Set(1) | |
configSuccessTime.SetToCurrentTime() | |
} else { | |
configSuccess.Set(0) | |
} | |
}() | |
conf, err := config.LoadFile(filename) | |
if err != nil { | |
return fmt.Errorf("couldn't load configuration (--config.file=%s): %v", filename, err) | |
} | |
failed := false | |
for _, rl := range rls { | |
if err := rl(conf); err != nil { | |
level.Error(logger).Log("msg", "Failed to apply configuration", "err", err) | |
failed = true | |
} | |
} | |
if failed { | |
return fmt.Errorf("one or more errors occurred while applying the new configuration (--config.file=%s)", filename) | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment