[#607] cmd/node: Empty Control server address as disable

In previous implementation if Control listen endpoint was omitted in config
the gRPC listening endpoint was used instead.

Consider empty address as an option to disable the service.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-22 19:27:47 +03:00 committed by Leonard Lyubich
parent c444118f47
commit d1eb9c3b0f

View file

@ -6,7 +6,6 @@ import (
"github.com/nspcc-dev/neofs-api-go/pkg/object"
controlconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/control"
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/services/control"
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
@ -14,6 +13,11 @@ import (
)
func initControlService(c *cfg) {
endpoint := controlconfig.GRPC(c.appCfg).Endpoint()
if endpoint == controlconfig.GRPCEndpointDefault {
return
}
pubs := controlconfig.AuthorizedKeys(c.appCfg)
rawPubs := make([][]byte, 0, len(pubs)+1) // +1 for node key
@ -38,21 +42,10 @@ func initControlService(c *cfg) {
}),
)
var (
err error
lis net.Listener
endpoint = controlconfig.GRPC(c.appCfg).Endpoint()
)
lis, err := net.Listen("tcp", endpoint)
fatalOnErr(err)
if endpoint == "" || endpoint == grpcconfig.Endpoint(c.appCfg) {
lis = c.cfgGRPC.listener
c.cfgControlService.server = c.cfgGRPC.server
} else {
lis, err = net.Listen("tcp", endpoint)
fatalOnErr(err)
c.cfgControlService.server = grpc.NewServer()
}
c.cfgControlService.server = grpc.NewServer()
c.onShutdown(func() {
stopGRPC("NeoFS Control API", c.cfgControlService.server, c.log)