File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
281281 "enable-pprof" ,
282282 "" ,
283283 false ,
284- "Enables the pprof profiling server on the agent (port: 6060 )." ,
284+ "Enables the pprof profiling endpoints on the agent server (port: 8081 )." ,
285285 )
286286 c .PersistentFlags ().BoolVarP (
287287 & cfg .Prometheus ,
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ import (
3434 "github.com/jetstack/preflight/pkg/logs"
3535 "github.com/jetstack/preflight/pkg/version"
3636
37- _ "net/http/pprof"
37+ "net/http/pprof"
3838)
3939
4040var Flags AgentCmdFlags
@@ -74,19 +74,18 @@ func Run(cmd *cobra.Command, args []string) {
7474 logs .Log .Fatalf ("While evaluating configuration: %v" , err )
7575 }
7676
77- if Flags .Profiling {
78- logs .Log .Printf ("pprof profiling was enabled.\n Running profiling on port :6060" )
79- go func () {
80- err := http .ListenAndServe (":6060" , nil )
81- if err != nil && ! errors .Is (err , http .ErrServerClosed ) {
82- logs .Log .Fatalf ("failed to run pprof profiler: %s" , err )
83- }
84- }()
85- }
86-
8777 go func () {
8878 server := http .NewServeMux ()
8979
80+ if Flags .Profiling {
81+ logs .Log .Printf ("pprof profiling was enabled." )
82+ server .HandleFunc ("/debug/pprof/" , pprof .Index )
83+ server .HandleFunc ("/debug/pprof/cmdline" , pprof .Cmdline )
84+ server .HandleFunc ("/debug/pprof/profile" , pprof .Profile )
85+ server .HandleFunc ("/debug/pprof/symbol" , pprof .Symbol )
86+ server .HandleFunc ("/debug/pprof/trace" , pprof .Trace )
87+ }
88+
9089 if Flags .Prometheus {
9190 logs .Log .Printf ("Prometheus was enabled.\n Running prometheus on port :8081" )
9291 prometheus .MustRegister (metricPayloadSize )
You can’t perform that action at this time.
0 commit comments