From cd742a6d18f3fbf9d14fe50b2c218dbfbddfb672 Mon Sep 17 00:00:00 2001 From: Ambor Date: Tue, 11 Apr 2023 11:13:36 +0800 Subject: [PATCH] fix: error port for the pprof server (#2766) Signed-off-by: saltbo --- pkg/utils/profile/profile.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/pkg/utils/profile/profile.go b/pkg/utils/profile/profile.go index fc796c47..308e42a2 100644 --- a/pkg/utils/profile/profile.go +++ b/pkg/utils/profile/profile.go @@ -25,7 +25,6 @@ package profile import ( "context" - "fmt" "net/http" _ "net/http/pprof" "os" @@ -35,26 +34,18 @@ import ( "github.com/fission/fission/pkg/utils/httpserver" ) -func getPprofAddr() string { - pprofHost := os.Getenv("PPROF_HOST") - if pprofHost == "" { - pprofHost = "localhost" - } - pprofPort := os.Getenv("PPROF_PORT") - if pprofPort == "" { - pprofPort = "6060" - } - return fmt.Sprintf("%s:%s", pprofHost, pprofPort) -} - func ProfileIfEnabled(ctx context.Context, logger *zap.Logger) { enablePprof := os.Getenv("PPROF_ENABLED") if enablePprof != "true" { return } + pprofPort := os.Getenv("PPROF_PORT") + if pprofPort == "" { + pprofPort = "6060" + } pprofMux := http.DefaultServeMux http.DefaultServeMux = http.NewServeMux() - go httpserver.StartServer(ctx, logger, "pprof", getPprofAddr(), pprofMux) + go httpserver.StartServer(ctx, logger, "pprof", pprofPort, pprofMux) }