Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add enable pprof flag for deamon #1416

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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