monitor must watch events even when context is cancelled

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2025-07-17 14:52:46 +02:00 committed by Guillaume Lours
parent 17ba6c7188
commit f35d2cfb3b
2 changed files with 3 additions and 5 deletions

View File

@ -79,7 +79,7 @@ func (c *monitor) Start(ctx context.Context) error {
}
restarting := utils.Set[string]{}
evtCh, errCh := c.api.Events(ctx, events.ListOptions{
evtCh, errCh := c.api.Events(context.Background(), events.ListOptions{
Filters: filters.NewArgs(
filters.Arg("type", "container"),
projectFilter(c.project)),
@ -89,8 +89,6 @@ func (c *monitor) Start(ctx context.Context) error {
return nil
}
select {
case <-ctx.Done():
return nil
case err := <-errCh:
return err
case event := <-evtCh:

View File

@ -111,6 +111,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
eg.Go(func() error {
first := true
gracefulTeardown := func() {
first = false
tui.ApplicationTermination()
eg.Go(func() error {
return progress.RunWithLog(context.WithoutCancel(ctx), func(ctx context.Context) error {
@ -121,7 +122,6 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
}, s.stdinfo(), logConsumer)
})
isTerminated.Store(true)
first = false
}
for {
@ -238,7 +238,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
})
eg.Go(func() error {
err := monitor.Start(ctx)
err := monitor.Start(context.Background())
// Signal for the signal-handler goroutines to stop
close(doneCh)
return err