[#2080] morph: Close morph clients

Could be related to "websocket users limit reached" on the `neo-go` server
side when an SN/IR is rebooting repeatedly.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-11-21 19:13:00 +03:00 committed by fyrchik
parent 3d0768a1d3
commit c01d4ecb50
3 changed files with 9 additions and 0 deletions

View file

@ -43,6 +43,7 @@ Changelog for NeoFS Node
- ObjectID signature output in the CLI (#2104) - ObjectID signature output in the CLI (#2104)
- Pack arguments of `setPrice` invocation during contract update (#2078) - Pack arguments of `setPrice` invocation during contract update (#2078)
- `neofs-cli object hash` panic (#2079) - `neofs-cli object hash` panic (#2079)
- Closing `neo-go` WS clients on shutdown and switch processes (#2080)
### Removed ### Removed
- `-g` option from `neofs-cli control ...` and `neofs-cli container create` commands (#2089) - `-g` option from `neofs-cli control ...` and `neofs-cli container create` commands (#2089)

View file

@ -62,6 +62,8 @@ func initMorphComponents(c *cfg) {
fatalOnErr(err) fatalOnErr(err)
} }
c.onShutdown(cli.Close)
if err := cli.SetGroupSignerScope(); err != nil { if err := cli.SetGroupSignerScope(); err != nil {
c.log.Info("failed to set group signer scope, continue with Global", zap.Error(err)) c.log.Info("failed to set group signer scope, continue with Global", zap.Error(err))
} }

View file

@ -153,6 +153,12 @@ func (c *Client) newCli(endpoint string) (*rpcclient.WSClient, *actor.Actor, err
return nil, nil, fmt.Errorf("WS client creation: %w", err) return nil, nil, fmt.Errorf("WS client creation: %w", err)
} }
defer func() {
if err != nil {
cli.Close()
}
}()
err = cli.Init() err = cli.Init()
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("WS client initialization: %w", err) return nil, nil, fmt.Errorf("WS client initialization: %w", err)