forked from TrueCloudLab/frostfs-node
[#493] cmd/node: Use new config for profiler configuration
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
561c809fa5
commit
da8310f0e3
2 changed files with 6 additions and 8 deletions
|
@ -51,10 +51,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// pprof keys
|
|
||||||
cfgProfilerAddr = "profiler.address"
|
|
||||||
cfgProfilerShutdownTimeout = "profiler.shutdown_timeout"
|
|
||||||
|
|
||||||
// metrics keys
|
// metrics keys
|
||||||
cfgMetricsAddr = "metrics.address"
|
cfgMetricsAddr = "metrics.address"
|
||||||
cfgMetricsShutdownTimeout = "metrics.shutdown_timeout"
|
cfgMetricsShutdownTimeout = "metrics.shutdown_timeout"
|
||||||
|
@ -149,6 +145,8 @@ const notificationHandlerPoolSize = 10
|
||||||
type cfg struct {
|
type cfg struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
|
||||||
|
appCfg *config.Config
|
||||||
|
|
||||||
ctxCancel func()
|
ctxCancel func()
|
||||||
|
|
||||||
internalErr chan error // channel for internal application errors at runtime
|
internalErr chan error // channel for internal application errors at runtime
|
||||||
|
@ -378,6 +376,7 @@ func initCfg(path string) *cfg {
|
||||||
|
|
||||||
c := &cfg{
|
c := &cfg{
|
||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
|
appCfg: appCfg,
|
||||||
internalErr: make(chan error),
|
internalErr: make(chan error),
|
||||||
viper: viperCfg,
|
viper: viperCfg,
|
||||||
log: log,
|
log: log,
|
||||||
|
@ -473,8 +472,6 @@ func defaultConfiguration(v *viper.Viper) {
|
||||||
|
|
||||||
v.SetDefault(cfgNetmapContract, "")
|
v.SetDefault(cfgNetmapContract, "")
|
||||||
|
|
||||||
v.SetDefault(cfgProfilerShutdownTimeout, "30s")
|
|
||||||
|
|
||||||
v.SetDefault(cfgMetricsShutdownTimeout, "30s")
|
v.SetDefault(cfgMetricsShutdownTimeout, "30s")
|
||||||
|
|
||||||
v.SetDefault(cfgPolicerHeadTimeout, 5*time.Second)
|
v.SetDefault(cfgPolicerHeadTimeout, 5*time.Second)
|
||||||
|
|
|
@ -3,12 +3,13 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
profilerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/profiler"
|
||||||
httputil "github.com/nspcc-dev/neofs-node/pkg/util/http"
|
httputil "github.com/nspcc-dev/neofs-node/pkg/util/http"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initProfiler(c *cfg) {
|
func initProfiler(c *cfg) {
|
||||||
addr := c.viper.GetString(cfgProfilerAddr)
|
addr := profilerconfig.Address(c.appCfg)
|
||||||
if addr == "" {
|
if addr == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -20,7 +21,7 @@ func initProfiler(c *cfg) {
|
||||||
|
|
||||||
srv := httputil.New(prm,
|
srv := httputil.New(prm,
|
||||||
httputil.WithShutdownTimeout(
|
httputil.WithShutdownTimeout(
|
||||||
c.viper.GetDuration(cfgProfilerShutdownTimeout),
|
profilerconfig.ShutdownTimeout(c.appCfg),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue