forked from TrueCloudLab/frostfs-node
[#579] cmd/node: Use new config for GRPC configuration
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
7dbeb08c58
commit
8a0a75a6b2
3 changed files with 10 additions and 16 deletions
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
||||||
engineconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine"
|
engineconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine"
|
||||||
shardconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard"
|
shardconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard"
|
||||||
|
grpcconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/grpc"
|
||||||
loggerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/logger"
|
loggerconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/logger"
|
||||||
metricsconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/metrics"
|
metricsconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/metrics"
|
||||||
nodeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/node"
|
nodeconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/node"
|
||||||
|
@ -53,12 +54,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// config keys for cfgGRPC
|
|
||||||
cfgListenAddress = "grpc.endpoint"
|
|
||||||
cfgTLSEnabled = "grpc.tls.enabled"
|
|
||||||
cfgTLSCertFile = "grpc.tls.certificate"
|
|
||||||
cfgTLSKeyFile = "grpc.tls.key"
|
|
||||||
|
|
||||||
// config keys for API client cache
|
// config keys for API client cache
|
||||||
cfgAPIClientDialTimeout = "apiclient.dial_timeout"
|
cfgAPIClientDialTimeout = "apiclient.dial_timeout"
|
||||||
|
|
||||||
|
@ -306,12 +301,14 @@ func initCfg(path string) *cfg {
|
||||||
tlsEnabled bool
|
tlsEnabled bool
|
||||||
tlsCertFile string
|
tlsCertFile string
|
||||||
tlsKeyFile string
|
tlsKeyFile string
|
||||||
|
|
||||||
|
tlsConfig = grpcconfig.TLS(appCfg)
|
||||||
)
|
)
|
||||||
|
|
||||||
if viperCfg.GetBool(cfgTLSEnabled) {
|
if tlsConfig.Enabled() {
|
||||||
tlsEnabled = true
|
tlsEnabled = true
|
||||||
tlsCertFile = viperCfg.GetString(cfgTLSCertFile)
|
tlsCertFile = tlsConfig.CertificateFile()
|
||||||
tlsKeyFile = viperCfg.GetString(cfgTLSKeyFile)
|
tlsKeyFile = tlsConfig.KeyFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
if tlsEnabled {
|
if tlsEnabled {
|
||||||
|
@ -412,11 +409,6 @@ func defaultConfiguration(v *viper.Viper) {
|
||||||
v.SetDefault(cfgMorphNotifyRPCAddress, []string{})
|
v.SetDefault(cfgMorphNotifyRPCAddress, []string{})
|
||||||
v.SetDefault(cfgMorphNotifyDialTimeout, 5*time.Second)
|
v.SetDefault(cfgMorphNotifyDialTimeout, 5*time.Second)
|
||||||
|
|
||||||
v.SetDefault(cfgListenAddress, "127.0.0.1:50501") // listen address
|
|
||||||
v.SetDefault(cfgTLSEnabled, false)
|
|
||||||
v.SetDefault(cfgTLSCertFile, "")
|
|
||||||
v.SetDefault(cfgTLSKeyFile, "")
|
|
||||||
|
|
||||||
v.SetDefault(cfgAPIClientDialTimeout, 5*time.Second)
|
v.SetDefault(cfgAPIClientDialTimeout, 5*time.Second)
|
||||||
|
|
||||||
v.SetDefault(cfgAccountingContract, "")
|
v.SetDefault(cfgAccountingContract, "")
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||||
|
grpcconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/grpc"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||||
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
|
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
|
||||||
|
@ -61,7 +62,7 @@ func initControlService(c *cfg) {
|
||||||
endpoint = c.viper.GetString(cfgCtrlGRPCEndpoint)
|
endpoint = c.viper.GetString(cfgCtrlGRPCEndpoint)
|
||||||
)
|
)
|
||||||
|
|
||||||
if endpoint == "" || endpoint == c.viper.GetString(cfgListenAddress) {
|
if endpoint == "" || endpoint == grpcconfig.Endpoint(c.appCfg) {
|
||||||
lis = c.cfgGRPC.listener
|
lis = c.cfgGRPC.listener
|
||||||
c.cfgControlService.server = c.cfgGRPC.server
|
c.cfgControlService.server = c.cfgGRPC.server
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
grpcconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/grpc"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
@ -13,7 +14,7 @@ import (
|
||||||
func initGRPC(c *cfg) {
|
func initGRPC(c *cfg) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.cfgGRPC.listener, err = net.Listen("tcp", c.viper.GetString(cfgListenAddress))
|
c.cfgGRPC.listener, err = net.Listen("tcp", grpcconfig.Endpoint(c.appCfg))
|
||||||
fatalOnErr(err)
|
fatalOnErr(err)
|
||||||
|
|
||||||
serverOpts := []grpc.ServerOption{
|
serverOpts := []grpc.ServerOption{
|
||||||
|
|
Loading…
Reference in a new issue