From 2859227fdbdefb96917028e75b25edaa65e6060c Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Fri, 8 Feb 2013 15:38:50 +0100 Subject: [PATCH] Make HTTP listen address a flag. --- web/web.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/web.go b/web/web.go index 0befd55e9..b26f7e71b 100644 --- a/web/web.go +++ b/web/web.go @@ -15,6 +15,7 @@ package web import ( "code.google.com/p/gorest" + "flag" "github.com/prometheus/client_golang" "github.com/prometheus/prometheus/storage/metric" "github.com/prometheus/prometheus/web/api" @@ -22,6 +23,11 @@ import ( _ "net/http/pprof" ) +// Commandline flags. +var ( + listenAddress = flag.String("listenAddress", ":9090", "Address to listen on for web interface.") +) + func StartServing(persistence metric.MetricPersistence) { gorest.RegisterService(api.NewMetricsService(persistence)) exporter := registry.DefaultRegistry.YieldExporter() @@ -30,5 +36,5 @@ func StartServing(persistence metric.MetricPersistence) { http.Handle("/metrics.json", exporter) http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("web/static")))) - go http.ListenAndServe(":9090", nil) + go http.ListenAndServe(*listenAddress, nil) }