-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathkubernetes-oom-event-generator.go
48 lines (37 loc) · 1.13 KB
/
kubernetes-oom-event-generator.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
package main
import (
"fmt"
"net/http"
"runtime"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/xing/kubernetes-oom-event-generator/src/controller"
"github.com/xing/kubernetes-oom-event-generator/src/util"
)
var opts struct {
Verbose int `env:"VERBOSE" short:"v" long:"verbose" description:"Show verbose debug information"`
Version bool `long:"version" description:"Print version information"`
}
// VERSION represents the current version of the release.
const VERSION = "v1.2.0"
func main() {
util.ParseArgs(&opts)
if opts.Version {
printVersion()
return
}
stopChan := make(chan struct{})
util.InstallSignalHandler(stopChan)
eventGenerator := controller.NewController(stopChan)
util.InstallSignalHandler(eventGenerator.Stop)
http.Handle("/metrics", promhttp.Handler())
addr := fmt.Sprintf("0.0.0.0:10254")
go func() { glog.Fatal(http.ListenAndServe(addr, nil)) }()
err := eventGenerator.Run()
if err != nil {
glog.Fatal(err)
}
}
func printVersion() {
fmt.Printf("kubernetes-oom-event-generator %s %s/%s %s\n", VERSION, runtime.GOOS, runtime.GOARCH, runtime.Version())
}