forked from TrueCloudLab/frostfs-node
[#70] cmd/neofs-node: Start asynchronous workers on app launch
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2b16edebc9
commit
9a604a50b9
3 changed files with 23 additions and 0 deletions
|
@ -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) {
|
||||
|
|
20
cmd/neofs-node/worker.go
Normal file
20
cmd/neofs-node/worker.go
Normal 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()
|
||||
}()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue