-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (39 loc) · 1.26 KB
/
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
package main
import (
"context"
"github.com/demoware/ingester/dispatcher"
"github.com/demoware/ingester/metrics"
"github.com/demoware/ingester/payload_handler/cpu_handler"
"github.com/demoware/ingester/payload_handler/last_kernel_update_handler"
"github.com/demoware/ingester/payload_handler/load_average_handler"
"net/http"
"os"
"os/signal"
"syscall"
)
func main() {
ctx, cancelFunc := context.WithCancel(context.Background())
options := dispatcher.DispatcherOptions{
BatchLimit: 10,
MetricsUri: "http://localhost:8080/metrics",
AuthToken: "deadbeef",
}
dispatcher := options.NewDispatcher()
cpuHandler := cpu_handler.NewCpuHandler()
lastKernelUpdateHandler := last_kernel_update_handler.NewLastKernelUpgradeHandler()
loadAverageHandler := load_average_handler.NewLoadAverageHandler()
dispatcher.NewHandler(cpuHandler)
dispatcher.NewHandler(lastKernelUpdateHandler)
dispatcher.NewHandler(loadAverageHandler)
go dispatcher.Start(ctx)
go cpuHandler.Start(ctx)
go lastKernelUpdateHandler.Start(ctx)
go loadAverageHandler.Start(ctx)
mux := http.NewServeMux()
mux.Handle("/metrics", metrics.Default)
http.ListenAndServe(":9020", mux)
termChan := make(chan os.Signal)
signal.Notify(termChan, syscall.SIGINT, syscall.SIGTERM)
<-termChan
cancelFunc()
}