git » prometheus-expvar-exporter » commit e9bf498

Fail in a better way if listen_addr is not set

author Alberto Bertogli
2019-10-31 20:57:38 UTC
committer Alberto Bertogli
2019-10-31 20:57:38 UTC
parent faaa4e65466518d38544ea4ea5b782f089b363e8

Fail in a better way if listen_addr is not set

main.go +3 -0

diff --git a/main.go b/main.go
index 4c852ae..4c582c0 100644
--- a/main.go
+++ b/main.go
@@ -61,6 +61,9 @@ func main() {
 	http.HandleFunc("/", indexHandler)
 	http.Handle("/metrics", promhttp.Handler())
 
+	if !config.Has("listen_addr") {
+		log.Fatal("Configuration has no listen_addr")
+	}
 	addr := config.Get("listen_addr").(string)
 	log.Printf("Listening on %q", addr)
 	log.Fatal(http.ListenAndServe(addr, nil))