forked from TrueCloudLab/frostfs-node
[#304] cmd/neofs-node: Catch closing channel of listener endpoint
As in #72 storage application should behave the same way at remote RPC node failures. The simplest way is to restart application. Later we can reinitialize it without downtime. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
1e170c3812
commit
3774c5d69a
3 changed files with 27 additions and 9 deletions
|
@ -1,10 +1,12 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/grace"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func fatalOnErr(err error) {
|
||||
|
@ -29,7 +31,7 @@ func main() {
|
|||
}
|
||||
|
||||
func initApp(c *cfg) {
|
||||
c.ctx = grace.NewGracefulContext(nil)
|
||||
c.ctx, c.ctxCancel = context.WithCancel(grace.NewGracefulContext(nil))
|
||||
|
||||
initGRPC(c)
|
||||
|
||||
|
@ -56,7 +58,15 @@ func bootUp(c *cfg) {
|
|||
func wait(c *cfg) {
|
||||
c.log.Info("application started")
|
||||
|
||||
<-c.ctx.Done()
|
||||
select {
|
||||
case <-c.ctx.Done(): // graceful shutdown
|
||||
case err := <-c.internalErr: // internal application error
|
||||
close(c.internalErr)
|
||||
c.ctxCancel()
|
||||
|
||||
c.log.Warn("internal application error",
|
||||
zap.String("message", err.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
func shutdown(c *cfg) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue