Skip to content

Commit

Permalink
start db first and stop it last
Browse files Browse the repository at this point in the history
  • Loading branch information
chappjc committed Feb 9, 2021
1 parent 172dbb7 commit b4ef3ff
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -904,17 +904,27 @@ func (c *Core) Run(ctx context.Context) {
c.ctx = ctx
c.initialize()
close(c.ready)
c.wg.Add(1)

// The DB starts first and stops last.
ctxDB, stopDB := context.WithCancel(context.Background())
var dbWG sync.WaitGroup
dbWG.Add(1)
go func() {
defer c.wg.Done()
c.db.Run(ctx)
defer dbWG.Done()
c.db.Run(ctxDB)
}()

c.wg.Add(1)
go func() {
defer c.wg.Done()
c.latencyQ.Run(ctx)
}()
c.wg.Wait()

// Stop the DB after dexConnections and other goroutines are done.
stopDB()
dbWG.Wait()

c.log.Infof("DEX client core off")
}

Expand Down

0 comments on commit b4ef3ff

Please sign in to comment.