mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* [NOD-1161] Name goroutines and log them by the name * [NOD-1161] Fix some goroutine names
25 lines
607 B
Go
25 lines
607 B
Go
package profiling
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
|
|
// Required for profiling
|
|
_ "net/http/pprof"
|
|
|
|
"github.com/kaspanet/kaspad/logs"
|
|
"github.com/kaspanet/kaspad/util/panics"
|
|
)
|
|
|
|
// Start starts the profiling server
|
|
func Start(port string, log *logs.Logger) {
|
|
spawn := panics.GoroutineWrapperFunc(log)
|
|
spawn("profiling.Start", func() {
|
|
listenAddr := net.JoinHostPort("", port)
|
|
log.Infof("Profile server listening on %s", listenAddr)
|
|
profileRedirect := http.RedirectHandler("/debug/pprof", http.StatusSeeOther)
|
|
http.Handle("/", profileRedirect)
|
|
log.Error(http.ListenAndServe(listenAddr, nil))
|
|
})
|
|
}
|