add pprof feature

This commit is contained in:
shiyan2016 2020-08-31 16:38:44 +08:00 committed by Siyu Wang
parent 7dc927e01e
commit b3df16a7c2
1 changed files with 14 additions and 2 deletions

16
main.go
View File

@ -18,6 +18,8 @@ package main
import (
"flag"
"net/http"
_ "net/http/pprof"
"os"
extclient "github.com/openkruise/kruise/pkg/client"
@ -53,9 +55,9 @@ func init() {
}
func main() {
var metricsAddr string
var metricsAddr, pprofAddr string
var healthProbeAddr string
var enableLeaderElection bool
var enableLeaderElection, enablePprof bool
var leaderElectionNamespace string
var namespace string
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.")
flag.StringVar(&namespace, "namespace", "",
"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)
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(klogr.New())