From bedf262d644f5fa35f29a67b5b772c86ccd15e66 Mon Sep 17 00:00:00 2001 From: Dmitriy Lukyanchikov <31628587+dmitriy-lukyanchikov@users.noreply.github.com> Date: Sun, 1 Apr 2018 12:20:41 +0300 Subject: [PATCH] Add config validation option (#306) --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index e0d586f..3520301 100644 --- a/main.go +++ b/main.go @@ -49,6 +49,7 @@ var ( configFile = kingpin.Flag("config.file", "Blackbox exporter configuration file.").Default("blackbox.yml").String() listenAddress = kingpin.Flag("web.listen-address", "The address to listen on for HTTP requests.").Default(":9115").String() timeoutOffset = kingpin.Flag("timeout-offset", "Offset to subtract from timeout in seconds.").Default("0.5").Float64() + configCheck = kingpin.Flag("config.check", "If true validate the config file and then exit.").Default().Bool() Probers = map[string]prober.ProbeFn{ "http": prober.ProbeHTTP, @@ -217,6 +218,12 @@ func main() { level.Error(logger).Log("msg", "Error loading config", "err", err) os.Exit(1) } + + if *configCheck { + level.Info(logger).Log("msg", "Config file is ok exiting...") + os.Exit(0) + } + level.Info(logger).Log("msg", "Loaded config file") hup := make(chan os.Signal) -- 2.25.1