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)
|
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)
|
cfg.web.ReadTimeout = time.Duration(cfg.webTimeout)
|
||||||
// Default -web.route-prefix to path of -web.external-url.
|
// Default -web.route-prefix to path of -web.external-url.
|
||||||
if cfg.web.RoutePrefix == "" {
|
if cfg.web.RoutePrefix == "" {
|
||||||
|
|
|
@ -111,7 +111,7 @@ func TestFailedStartupExitCode(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fakeInputFile := "fake-input-file"
|
fakeInputFile := "fake-input-file"
|
||||||
expectedExitStatus := 1
|
expectedExitStatus := 2
|
||||||
|
|
||||||
prom := exec.Command(promPath, "-test.main", "--config.file="+fakeInputFile)
|
prom := exec.Command(promPath, "-test.main", "--config.file="+fakeInputFile)
|
||||||
err := prom.Run()
|
err := prom.Run()
|
||||||
|
|
Loading…
Reference in New Issue