Skip to content

Commit

Permalink
Wait for ctx.Done
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed Dec 12, 2024
1 parent a256595 commit 03d647e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions internal/app/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ func (s Setup) Run(ctx context.Context) error {
if err := s.HTTPServer.Start(ctx); err != nil {
return err
}
ctxShutdown, cancel := context.WithTimeout(ctx, 1*time.Second)
defer cancel()
// Try to end before 1s…
s.HTTPServer.WaitShutdown(ctxShutdown)
s.Upf.WaitShutdown(ctxShutdown)
select {
case <-ctx.Done():
ctxShutdown, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
// Try to end before 1s…
s.HTTPServer.WaitShutdown(ctxShutdown)
s.Upf.WaitShutdown(ctxShutdown)
}
return nil
}

0 comments on commit 03d647e

Please sign in to comment.