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) {
|
||||
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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue