Make HTTP listen address a flag.

This commit is contained in:
Julius Volz 2013-02-08 15:38:50 +01:00
parent 0cbd03ccf9
commit 2859227fdb

View File

@ -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)
}