Skip to content

Commit

Permalink
Move pprof server listener start to if check for profiling (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
pharr117 authored Feb 11, 2025
1 parent f0cadd3 commit b01a3e7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,17 @@ func rootCmd() *cobra.Command {
}

func startManager(cmd *cobra.Command, args []string) error {
go func() {
setupLog.Info("Serving pprof endpoints at localhost:6060/debug/pprof")
if err := http.ListenAndServe("localhost:6060", nil); err != nil {
setupLog.Error(err, "Pprof server exited with error")
}
}()

logger := opcmd.ZapLogger(logLevel, logFormat)
defer func() { _ = logger.Sync() }()
ctrl.SetLogger(zapr.NewLogger(logger))

if profileMode != "" {
go func() {
setupLog.Info("Serving pprof endpoints at localhost:6060/debug/pprof")
if err := http.ListenAndServe("localhost:6060", nil); err != nil {
setupLog.Error(err, "Pprof server exited with error")
}
}()
defer profile.Start(profileOpts(profileMode)...).Stop()
}

Expand Down

0 comments on commit b01a3e7

Please sign in to comment.