Skip to content

Commit

Permalink
feature request that add enable pprof flag for deamon (openkruise#1416)
Browse files Browse the repository at this point in the history
  • Loading branch information
chengjoey authored Sep 19, 2023
1 parent 154db5f commit 4d715e3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmd/daemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ import (
)

var (
bindAddr = flag.String("addr", ":10221", "The address the metric endpoint and healthz binds to.")
pprofAddr = flag.String("pprof-addr", ":10222", "The address the pprof binds to.")
bindAddr = flag.String("addr", ":10221", "The address the metric endpoint and healthz binds to.")
pprofAddr = flag.String("pprof-addr", ":10222", "The address the pprof binds to.")
enablePprof = flag.Bool("enable-pprof", true, "Enable pprof for daemon.")
)

func main() {
Expand All @@ -55,11 +56,13 @@ func main() {
if err := client.NewRegistry(cfg); err != nil {
klog.Fatalf("Failed to init clientset registry: %v", err)
}
go func() {
if err := http.ListenAndServe(*pprofAddr, nil); err != nil {
klog.Fatal(err, "unable to start pprof")
}
}()
if enablePprof != nil && *enablePprof {
go func() {
if err := http.ListenAndServe(*pprofAddr, nil); err != nil {
klog.Fatal(err, "unable to start pprof")
}
}()
}
ctx := signals.SetupSignalHandler()
d, err := daemon.NewDaemon(cfg, *bindAddr)
if err != nil {
Expand Down

0 comments on commit 4d715e3

Please sign in to comment.