pihole-exporter/main.go
Vanetta 26ddc36a4e only scrape when asked
will only scape metrics on pihole when asked on /metrics
allow port 0 to be used when using strict https redirects

Resolves: #49
2021-08-16 23:55:05 +02:00

39 lines
662 B
Go

package main
import (
"fmt"
"github.com/eko/pihole-exporter/config"
"github.com/eko/pihole-exporter/internal/metrics"
"github.com/eko/pihole-exporter/internal/pihole"
"github.com/eko/pihole-exporter/internal/server"
"github.com/xonvanetta/shutdown/pkg/shutdown"
)
func main() {
conf := config.Load()
metrics.Init()
serverDead := make(chan struct{})
s := server.NewServer(conf.Port, pihole.NewClient(conf))
go func() {
s.ListenAndServe()
close(serverDead)
}()
ctx := shutdown.Context()
go func() {
<-ctx.Done()
s.Stop()
}()
select {
case <-ctx.Done():
case <-serverDead:
}
fmt.Println("pihole-exporter HTTP server stopped")
}