-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
38 lines (31 loc) · 747 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
package main
import (
"fmt"
"github.com/DictumMortuum/modem-exporter/config"
"github.com/DictumMortuum/modem-exporter/internal/metrics"
"github.com/DictumMortuum/modem-exporter/internal/modem"
"github.com/DictumMortuum/modem-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, modem.NewClient(conf))
fmt.Println(conf)
go func() {
s.ListenAndServe()
close(serverDead)
}()
ctx := shutdown.Context()
go func() {
<-ctx.Done()
s.Stop()
}()
select {
case <-ctx.Done():
case <-serverDead:
}
version := "0.0.11"
fmt.Printf("modem-exporter v%s HTTP server stopped\n", version)
}