mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2025-01-11 11:55:41 +00:00
20 lines
405 B
Go
20 lines
405 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 func() {
|
|
fmt.Fprintf(os.Stderr, "DEBUG: %s", http.ListenAndServe(hostPort, nil))
|
|
}()
|
|
}
|
|
}
|