[#323] cmd/node: Compose functions for closing components in app
Closing callback can be registered in app through onShutdown method. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
707434efa9
commit
9f41192bff
4 changed files with 29 additions and 4 deletions
|
@ -78,12 +78,15 @@ func wait(c *cfg) {
|
|||
}
|
||||
|
||||
func shutdown(c *cfg) {
|
||||
c.cfgGRPC.server.GracefulStop()
|
||||
c.cfgControlService.server.GracefulStop()
|
||||
|
||||
c.log.Info("gRPC server stopped")
|
||||
for _, closer := range c.closers {
|
||||
closer()
|
||||
}
|
||||
|
||||
goOffline(c)
|
||||
|
||||
c.wg.Wait()
|
||||
}
|
||||
|
||||
func (c *cfg) onShutdown(f func()) {
|
||||
c.closers = append(c.closers, f)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue