Files
yggdrasil-go/src/core/debug.go

20 lines
405 B
Go
Raw Normal View History

2021-05-23 14:42:26 -05:00
package core
2017-12-28 22:16:20 -06:00
2022-04-17 18:02:25 +01:00
import (
"fmt"
"net/http"
_ "net/http/pprof"
"os"
)
2019-01-27 13:33:32 +00:00
2023-10-21 21:36:28 +01:00
// Start the profiler if the required environment variable is set.
func init() {
envVarName := "PPROFLISTEN"
2023-10-22 10:29:19 +01:00
if hostPort := os.Getenv(envVarName); hostPort != "" {
fmt.Fprintf(os.Stderr, "DEBUG: Starting pprof on %s\n", hostPort)
2023-11-28 13:24:54 +00:00
go func() {
fmt.Fprintf(os.Stderr, "DEBUG: %s", http.ListenAndServe(hostPort, nil))
}()
}
}