mirror of
https://github.com/prometheus/prometheus
synced 2024-12-24 07:23:02 +00:00
Make HTTP listen address a flag.
This commit is contained in:
parent
0cbd03ccf9
commit
2859227fdb
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user