diff --git a/scopes.go b/scopes.go index b864a4c..61ed059 100644 --- a/scopes.go +++ b/scopes.go @@ -17,6 +17,14 @@ type Cfg struct { } 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() { cctx := ctx.ChildContext(cfg) cfg.Starter()(cctx) @@ -25,8 +33,9 @@ func Start(ctx common.Context) { fmt.Println("running ", ctx.WaitGroup()) defer func() { close(ctx.Done()) - ctx.WaitGroup().Wait() - fmt.Println("finishing ", ctx.WaitGroup()) + fmt.Println("finishing #1 ", ctx.WaitGroup()) + //ctx.WaitGroup().Wait() + //fmt.Println("finishing #2 ", ctx.WaitGroup()) //ctx.LogDebug("Dispatcher exited", m.Map{}) }() 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) { ctx := common.AppContext(cfg) cfg.Starter()(ctx) + ctx.WaitGroup().Wait() } diff --git a/testing/testing.go b/testing/testing.go index 87510fd..3c3e591 100644 --- a/testing/testing.go +++ b/testing/testing.go @@ -54,7 +54,7 @@ func (t *T) TearDownApp() { //t.Check() t.Ctx.Services()["testing"].Mailbox() <- "quit" fmt.Println("teardown ", t.Ctx.WaitGroup()) - //t.Ctx.WaitGroup().Wait() + t.Ctx.WaitGroup().Wait() //t.AssertNoUncheckedMessages() }