node: Drain internal error's channel (support/v0.37) #879
2 changed files with 15 additions and 2 deletions
|
@ -1162,9 +1162,8 @@ func (c *cfg) shutdown() {
|
|||
c.setHealthStatus(control.HealthStatus_SHUTTING_DOWN)
|
||||
|
||||
c.ctxCancel()
|
||||
c.done <- struct{}{}
|
||||
close(c.done)
|
||||
for i := range c.closers {
|
||||
c.closers[len(c.closers)-1-i].fn()
|
||||
}
|
||||
close(c.internalErr)
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
|
@ -148,9 +149,22 @@ func wait(c *cfg) {
|
|||
|
||||
<-c.done // graceful shutdown
|
||||
|
||||
drain := &sync.WaitGroup{}
|
||||
drain.Add(1)
|
||||
go func() {
|
||||
defer drain.Done()
|
||||
for err := range c.internalErr {
|
||||
c.log.Warn(logs.FrostFSNodeInternalApplicationError,
|
||||
zap.String("message", err.Error()))
|
||||
}
|
||||
}()
|
||||
|
||||
c.log.Debug(logs.FrostFSNodeWaitingForAllProcessesToStop)
|
||||
|
||||
c.wg.Wait()
|
||||
|
||||
close(c.internalErr)
|
||||
drain.Wait()
|
||||
}
|
||||
|
||||
func (c *cfg) onShutdown(f func()) {
|
||||
|
|
Loading…
Reference in a new issue