2020-10-02 13:18:38 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-05-11 22:59:05 +00:00
|
|
|
"context"
|
|
|
|
|
2021-06-01 11:13:44 +00:00
|
|
|
profilerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/profiler"
|
2021-05-11 22:59:05 +00:00
|
|
|
httputil "github.com/nspcc-dev/neofs-node/pkg/util/http"
|
|
|
|
"go.uber.org/zap"
|
2020-10-02 13:18:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func initProfiler(c *cfg) {
|
2021-06-01 11:13:44 +00:00
|
|
|
addr := profilerconfig.Address(c.appCfg)
|
2021-05-11 22:59:05 +00:00
|
|
|
if addr == "" {
|
|
|
|
return
|
2020-10-02 13:18:38 +00:00
|
|
|
}
|
2021-05-11 22:59:05 +00:00
|
|
|
|
|
|
|
var prm httputil.Prm
|
|
|
|
|
|
|
|
prm.Address = addr
|
|
|
|
prm.Handler = httputil.Handler()
|
|
|
|
|
|
|
|
srv := httputil.New(prm,
|
|
|
|
httputil.WithShutdownTimeout(
|
2021-06-01 11:13:44 +00:00
|
|
|
profilerconfig.ShutdownTimeout(c.appCfg),
|
2021-05-11 22:59:05 +00:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
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()),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
})
|
2020-10-02 13:18:38 +00:00
|
|
|
}
|