mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
Exit early on invalid config file (#7399)
* Reload config file at start Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com> * relocated config checking Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com> * change log lever Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com> * add helpful comment Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com>
This commit is contained in:
parent
27f89ac651
commit
70b0a34616
|
@ -278,6 +278,12 @@ func main() {
|
|||
os.Exit(2)
|
||||
}
|
||||
|
||||
// Throw error for invalid config before starting other components.
|
||||
if _, err := config.LoadFile(cfg.configFile); err != nil {
|
||||
level.Error(logger).Log("msg", fmt.Sprintf("Error loading config (--config.file=%s)", cfg.configFile), "err", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
cfg.web.ReadTimeout = time.Duration(cfg.webTimeout)
|
||||
// Default -web.route-prefix to path of -web.external-url.
|
||||
if cfg.web.RoutePrefix == "" {
|
||||
|
|
|
@ -111,7 +111,7 @@ func TestFailedStartupExitCode(t *testing.T) {
|
|||
}
|
||||
|
||||
fakeInputFile := "fake-input-file"
|
||||
expectedExitStatus := 1
|
||||
expectedExitStatus := 2
|
||||
|
||||
prom := exec.Command(promPath, "-test.main", "--config.file="+fakeInputFile)
|
||||
err := prom.Run()
|
||||
|
|
Loading…
Reference in a new issue