4
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2025-07-11 10:46:28 +00:00
Files
yggdrasil-go/src/core/debug.go
2023-10-22 10:29:19 +01:00

18 lines
363 B
Go

package core
import (
"fmt"
"net/http"
_ "net/http/pprof"
"os"
)
// Start the profiler if the required environment variable is set.
func init() {
envVarName := "PPROFLISTEN"
if hostPort := os.Getenv(envVarName); hostPort != "" {
fmt.Fprintf(os.Stderr, "DEBUG: Starting pprof on %s\n", hostPort)
go fmt.Println(http.ListenAndServe(hostPort, nil))
}
}