Fix several async issues
- race conditions between ctx.Done and waitError channel - Sleep for retry cancels on cancelation of context - Stops the any loop at the start if the context was canceled - Mentions when loops exit - Wait for errors on triggered loop restarts
This commit is contained in:
@@ -37,6 +37,7 @@ func (s *server) Run(ctx context.Context, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
<-ctx.Done()
|
||||
s.logger.Warn("context canceled: exiting loop")
|
||||
defer s.logger.Warn("loop exited")
|
||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
if err := server.Shutdown(shutdownCtx); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user