mirror of
https://github.com/eko/pihole-exporter.git
synced 2024-11-24 11:37:03 +01:00
26ddc36a4e
will only scape metrics on pihole when asked on /metrics allow port 0 to be used when using strict https redirects Resolves: #49
39 lines
662 B
Go
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")
|
|
}
|