frostfs-node/cmd/neofs-node/pprof.go
Alex Vanin da8310f0e3 [#493] cmd/node: Use new config for profiler configuration
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-06-01 15:29:08 +03:00

40 lines
776 B
Go

package main
import (
"context"
profilerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/profiler"
httputil "github.com/nspcc-dev/neofs-node/pkg/util/http"
"go.uber.org/zap"
)
func initProfiler(c *cfg) {
addr := profilerconfig.Address(c.appCfg)
if addr == "" {
return
}
var prm httputil.Prm
prm.Address = addr
prm.Handler = httputil.Handler()
srv := httputil.New(prm,
httputil.WithShutdownTimeout(
profilerconfig.ShutdownTimeout(c.appCfg),
),
)
c.workers = append(c.workers, newWorkerFromFunc(func(context.Context) {
fatalOnErr(srv.Serve())
}))
c.closers = append(c.closers, func() {
err := srv.Shutdown()
if err != nil {
c.log.Debug("could not shutdown pprof server",
zap.String("error", err.Error()),
)
}
})
}