From 80e56eafcdb620b61c4e60256d757d826d31b37a Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 21 Oct 2023 21:36:28 +0100 Subject: [PATCH] Allow `PPROFLISTEN` on all builds --- src/core/debug.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/core/debug.go b/src/core/debug.go index 6085ceeb..23139f9a 100644 --- a/src/core/debug.go +++ b/src/core/debug.go @@ -1,6 +1,3 @@ -//go:build debug -// +build debug - package core import ( @@ -8,12 +5,9 @@ import ( "net/http" _ "net/http/pprof" "os" - "runtime" - - "github.com/gologme/log" ) -// Start the profiler in debug builds, if the required environment variable is set. +// Start the profiler if the required environment variable is set. func init() { envVarName := "PPROFLISTEN" hostPort := os.Getenv(envVarName) @@ -22,14 +16,6 @@ func init() { fmt.Fprintf(os.Stderr, "DEBUG: %s not set, profiler not started.\n", envVarName) default: fmt.Fprintf(os.Stderr, "DEBUG: Starting pprof on %s\n", hostPort) - go func() { fmt.Println(http.ListenAndServe(hostPort, nil)) }() + go fmt.Println(http.ListenAndServe(hostPort, nil)) } } - -// Starts the function profiler. This is only supported when built with -// '-tags build'. -func StartProfiler(log *log.Logger) error { - runtime.SetBlockProfileRate(1) - go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }() - return nil -}