-
Notifications
You must be signed in to change notification settings - Fork 433
/
speaker.go
41 lines (32 loc) · 853 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
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/versions"
)
func CmdMain() {
defer klog.Flush()
klog.Infof(versions.String())
config, err := speaker.ParseFlags()
if err != nil {
klog.Fatalf("failed to parse config %v", err)
}
stopCh := signals.SetupSignalHandler()
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,
}
klog.Fatal(server.ListenAndServe())
}()
ctl.Run(stopCh)
}