mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
internal/debug: start pprof server by new function StartPProf (#16532)
This commit is contained in:
parent
66da805ccd
commit
23bc924585
1 changed files with 13 additions and 10 deletions
|
|
@ -312,17 +312,8 @@ func Setup(ctx *cli.Context) error {
|
|||
|
||||
// pprof server
|
||||
if ctx.Bool(pprofFlag.Name) {
|
||||
// Hook go-metrics into expvar on any /debug/metrics request, load all vars
|
||||
// from the registry into expvar, and execute regular expvar handler.
|
||||
exp.Exp(metrics.DefaultRegistry)
|
||||
|
||||
address := fmt.Sprintf("%s:%d", ctx.String(pprofAddrFlag.Name), ctx.Int(pprofPortFlag.Name))
|
||||
go func() {
|
||||
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
|
||||
if err := http.ListenAndServe(address, nil); err != nil {
|
||||
log.Error("Failure in running pprof server", "err", err)
|
||||
}
|
||||
}()
|
||||
StartPProf(address)
|
||||
}
|
||||
|
||||
if len(logFile) > 0 || rotation {
|
||||
|
|
@ -332,6 +323,18 @@ func Setup(ctx *cli.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func StartPProf(address string) {
|
||||
// Hook go-metrics into expvar on any /debug/metrics request, load all vars
|
||||
// from the registry into expvar, and execute regular expvar handler.
|
||||
exp.Exp(metrics.DefaultRegistry)
|
||||
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
|
||||
go func() {
|
||||
if err := http.ListenAndServe(address, nil); err != nil {
|
||||
log.Error("Failure in running pprof server", "err", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Exit stops all running profiles, flushing their output to the
|
||||
// respective file.
|
||||
func Exit() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue