[#70] cmd/neofs-node: Start asynchronous workers on app launch

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-10-03 12:57:02 +03:00 committed by Alex Vanin
parent 2b16edebc9
commit 9a604a50b9
3 changed files with 23 additions and 0 deletions

View file

@ -105,6 +105,8 @@ type cfg struct {
cfgObject cfgObject
profiler profiler.Profiler
workers []worker
}
type cfgGRPC struct {

View file

@ -44,6 +44,7 @@ func bootUp(c *cfg) {
serveProfiler(c)
serveGRPC(c)
bootstrapNode(c)
startWorkers(c)
}
func wait(c *cfg) {

20
cmd/neofs-node/worker.go Normal file
View file

@ -0,0 +1,20 @@
package main
import (
"context"
)
type worker interface {
Run(context.Context)
}
func startWorkers(c *cfg) {
for _, wrk := range c.workers {
c.wg.Add(1)
go func() {
wrk.Run(c.ctx)
c.wg.Done()
}()
}
}