1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-27 06:38:44 +02:00

Restructure configuration

This commit is contained in:
Alexandre Iooss
2020-09-22 11:42:57 +02:00
parent c799a5b613
commit 5ac336393b
11 changed files with 107 additions and 104 deletions

View File

@ -7,9 +7,13 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"gitlab.crans.org/nounous/ghostream/internal/config"
)
// Options holds web package configuration
type Options struct {
ListenAddress string
}
var (
// ViewerServed is the total amount of viewer page served
ViewerServed = promauto.NewCounter(prometheus.CounterOpts{
@ -19,9 +23,9 @@ var (
)
// ServeHTTP server that expose prometheus metrics
func ServeHTTP(cfg *config.Config) {
func ServeHTTP(cfg *Options) {
mux := http.NewServeMux()
mux.Handle("/metrics", promhttp.Handler())
log.Printf("Monitoring listening on http://%s/", cfg.Prometheus.ListenAddress)
log.Fatal(http.ListenAndServe(cfg.Prometheus.ListenAddress, mux))
log.Printf("Monitoring HTTP server listening on %s", cfg.ListenAddress)
log.Fatal(http.ListenAndServe(cfg.ListenAddress, mux))
}