2021-05-23 19:42:26 +00:00
|
|
|
package core
|
2017-12-29 04:16:20 +00:00
|
|
|
|
2022-04-17 17:02:25 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
_ "net/http/pprof"
|
|
|
|
"os"
|
|
|
|
)
|
2019-01-27 13:33:32 +00:00
|
|
|
|
2023-10-21 20:36:28 +00:00
|
|
|
// Start the profiler if the required environment variable is set.
|
2018-06-21 15:32:16 +00:00
|
|
|
func init() {
|
|
|
|
envVarName := "PPROFLISTEN"
|
2023-10-22 09:29:19 +00:00
|
|
|
if hostPort := os.Getenv(envVarName); hostPort != "" {
|
2019-07-20 20:56:53 +00:00
|
|
|
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))
|
|
|
|
}()
|
2018-06-21 15:32:16 +00:00
|
|
|
}
|
|
|
|
}
|