forked from TrueCloudLab/frostfs-node
[#70] cmd/neofs-node: Start asynchronous workers on app launch
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>support/v0.27
parent
2b16edebc9
commit
9a604a50b9
|
@ -105,6 +105,8 @@ type cfg struct {
|
|||
cfgObject cfgObject
|
||||
|
||||
profiler profiler.Profiler
|
||||
|
||||
workers []worker
|
||||
}
|
||||
|
||||
type cfgGRPC struct {
|
||||
|
|
|
@ -44,6 +44,7 @@ func bootUp(c *cfg) {
|
|||
serveProfiler(c)
|
||||
serveGRPC(c)
|
||||
bootstrapNode(c)
|
||||
startWorkers(c)
|
||||
}
|
||||
|
||||
func wait(c *cfg) {
|
||||
|
|
|
@ -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()
|
||||
}()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue