-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
49 lines (35 loc) · 859 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Package main takes care of the initialization of the application.
package main
import (
"os"
"os/signal"
"syscall"
"github.com/kinduff/firefly_iii_exporter/config"
"github.com/kinduff/firefly_iii_exporter/internal/collector"
"github.com/kinduff/firefly_iii_exporter/internal/metrics"
"github.com/kinduff/firefly_iii_exporter/internal/server"
log "github.com/sirupsen/logrus"
)
var (
s *server.Server
)
func main() {
cfg := config.Load()
cfg.Show()
metrics.Init(cfg)
client := collector.NewCollector(cfg)
go client.Scrape()
initHTTPServer(cfg.HTTPPort)
handleExitSignal()
}
func initHTTPServer(port string) {
s = server.NewServer(port)
go s.ListenAndServe()
}
func handleExitSignal() {
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
<-stop
s.Stop()
log.Fatal("HTTP server stopped")
}