mirror of https://github.com/openkruise/kruise.git
add pprof feature
This commit is contained in:
parent
7dc927e01e
commit
b3df16a7c2
16
main.go
16
main.go
|
@ -18,6 +18,8 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
extclient "github.com/openkruise/kruise/pkg/client"
|
extclient "github.com/openkruise/kruise/pkg/client"
|
||||||
|
@ -53,9 +55,9 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var metricsAddr string
|
var metricsAddr, pprofAddr string
|
||||||
var healthProbeAddr string
|
var healthProbeAddr string
|
||||||
var enableLeaderElection bool
|
var enableLeaderElection, enablePprof bool
|
||||||
var leaderElectionNamespace string
|
var leaderElectionNamespace string
|
||||||
var namespace string
|
var namespace string
|
||||||
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
|
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
|
||||||
|
@ -65,10 +67,20 @@ func main() {
|
||||||
"This determines the namespace in which the leader election configmap will be created, it will use in-cluster namespace if empty.")
|
"This determines the namespace in which the leader election configmap will be created, it will use in-cluster namespace if empty.")
|
||||||
flag.StringVar(&namespace, "namespace", "",
|
flag.StringVar(&namespace, "namespace", "",
|
||||||
"Namespace if specified restricts the manager's cache to watch objects in the desired namespace. Defaults to all namespaces.")
|
"Namespace if specified restricts the manager's cache to watch objects in the desired namespace. Defaults to all namespaces.")
|
||||||
|
flag.BoolVar(&enablePprof, "enable-pprof", false, "Enable pprof for controller manager.")
|
||||||
|
flag.StringVar(&pprofAddr, "pprof-addr", ":8090", "The address the pprof binds to.")
|
||||||
|
|
||||||
klog.InitFlags(nil)
|
klog.InitFlags(nil)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if enablePprof {
|
||||||
|
go func() {
|
||||||
|
if err := http.ListenAndServe(pprofAddr, nil); err != nil {
|
||||||
|
setupLog.Error(err, "unable to start pprof")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
//ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
|
//ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
|
||||||
ctrl.SetLogger(klogr.New())
|
ctrl.SetLogger(klogr.New())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue