app start as Goroutine basically working
This commit is contained in:
parent
0f0ed437d9
commit
c6aa6afae2
2 changed files with 13 additions and 3 deletions
14
scopes.go
14
scopes.go
|
@ -17,6 +17,14 @@ type Cfg struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Start(ctx common.Context) {
|
func Start(ctx common.Context) {
|
||||||
|
ctx.WaitGroup().Add(1)
|
||||||
|
go func() {
|
||||||
|
start(ctx)
|
||||||
|
ctx.WaitGroup().Done()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func start(ctx common.Context) {
|
||||||
for _, cfg := range ctx.Config().Children() {
|
for _, cfg := range ctx.Config().Children() {
|
||||||
cctx := ctx.ChildContext(cfg)
|
cctx := ctx.ChildContext(cfg)
|
||||||
cfg.Starter()(cctx)
|
cfg.Starter()(cctx)
|
||||||
|
@ -25,8 +33,9 @@ func Start(ctx common.Context) {
|
||||||
fmt.Println("running ", ctx.WaitGroup())
|
fmt.Println("running ", ctx.WaitGroup())
|
||||||
defer func() {
|
defer func() {
|
||||||
close(ctx.Done())
|
close(ctx.Done())
|
||||||
ctx.WaitGroup().Wait()
|
fmt.Println("finishing #1 ", ctx.WaitGroup())
|
||||||
fmt.Println("finishing ", ctx.WaitGroup())
|
//ctx.WaitGroup().Wait()
|
||||||
|
//fmt.Println("finishing #2 ", ctx.WaitGroup())
|
||||||
//ctx.LogDebug("Dispatcher exited", m.Map{})
|
//ctx.LogDebug("Dispatcher exited", m.Map{})
|
||||||
}()
|
}()
|
||||||
sig := make(chan os.Signal, 1)
|
sig := make(chan os.Signal, 1)
|
||||||
|
@ -58,4 +67,5 @@ func step(ctx common.Context, sig <-chan os.Signal) bool {
|
||||||
func RunApp(cfg common.Config) {
|
func RunApp(cfg common.Config) {
|
||||||
ctx := common.AppContext(cfg)
|
ctx := common.AppContext(cfg)
|
||||||
cfg.Starter()(ctx)
|
cfg.Starter()(ctx)
|
||||||
|
ctx.WaitGroup().Wait()
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ func (t *T) TearDownApp() {
|
||||||
//t.Check()
|
//t.Check()
|
||||||
t.Ctx.Services()["testing"].Mailbox() <- "quit"
|
t.Ctx.Services()["testing"].Mailbox() <- "quit"
|
||||||
fmt.Println("teardown ", t.Ctx.WaitGroup())
|
fmt.Println("teardown ", t.Ctx.WaitGroup())
|
||||||
//t.Ctx.WaitGroup().Wait()
|
t.Ctx.WaitGroup().Wait()
|
||||||
//t.AssertNoUncheckedMessages()
|
//t.AssertNoUncheckedMessages()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue