github.com/yggdrasil-network/yggdrasil-go@v0.5.6/src/core/debug.go (about) 1 package core 2 3 import ( 4 "fmt" 5 "net/http" 6 _ "net/http/pprof" 7 "os" 8 ) 9 10 // Start the profiler if the required environment variable is set. 11 func init() { 12 envVarName := "PPROFLISTEN" 13 if hostPort := os.Getenv(envVarName); hostPort != "" { 14 fmt.Fprintf(os.Stderr, "DEBUG: Starting pprof on %s\n", hostPort) 15 go func() { 16 fmt.Fprintf(os.Stderr, "DEBUG: %s", http.ListenAndServe(hostPort, nil)) 17 }() 18 } 19 }