-
Notifications
You must be signed in to change notification settings - Fork 438
/
speaker.go
42 lines (33 loc) · 965 Bytes
/
speaker.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
package speaker
import (
"fmt"
"net/http"
"time"
"github.com/prometheus/client_golang/prometheus/promhttp"
"k8s.io/klog/v2"
"k8s.io/sample-controller/pkg/signals"
"github.com/kubeovn/kube-ovn/pkg/speaker"
"github.com/kubeovn/kube-ovn/pkg/util"
"github.com/kubeovn/kube-ovn/versions"
)
func CmdMain() {
defer klog.Flush()
klog.Infof(versions.String())
config, err := speaker.ParseFlags()
if err != nil {
util.LogFatalAndExit(err, "failed to parse config")
}
stopCh := signals.SetupSignalHandler().Done()
ctl := speaker.NewController(config)
go func() {
http.Handle("/metrics", promhttp.Handler())
// conform to Gosec G114
// https://github.com/securego/gosec#available-rules
server := &http.Server{
Addr: fmt.Sprintf("0.0.0.0:%d", config.PprofPort),
ReadHeaderTimeout: 3 * time.Second,
}
util.LogFatalAndExit(server.ListenAndServe(), "failed to listen and serve on %s", server.Addr)
}()
ctl.Run(stopCh)
}