mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
start the pprof based on an env variable in debug builds, otherwise remove the flag/release.go stuff
This commit is contained in:
parent
7a19507665
commit
f599a1a2c1
3 changed files with 14 additions and 21 deletions
|
@ -20,6 +20,20 @@ import "regexp"
|
|||
import _ "net/http/pprof"
|
||||
import "net/http"
|
||||
import "runtime"
|
||||
import "os"
|
||||
|
||||
// Start the profiler in debug builds, if the required environment variable is set.
|
||||
func init() {
|
||||
envVarName := "PPROFLISTEN"
|
||||
hostPort := os.Getenv(envVarName)
|
||||
switch {
|
||||
case hostPort == "":
|
||||
fmt.Printf("DEBUG: %s not set, profiler not started.\n", envVarName)
|
||||
default:
|
||||
fmt.Printf("DEBUG: Starting pprof on %s\n", hostPort)
|
||||
go func() { fmt.Println(http.ListenAndServe(hostPort, nil)) }()
|
||||
}
|
||||
}
|
||||
|
||||
// Starts the function profiler. This is only supported when built with
|
||||
// '-tags build'.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue