Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
run ContainerWait in background so we catch container exit
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Mar 22, 2021
1 parent 8347556 commit 9af5ea4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion local/compose/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *composeService) attach(ctx context.Context, project *types.Project, lis
s.attachContainer(ctx, container, listener, project) // nolint: errcheck
delete(crashed, event.Container)

s.waitContainer(ctx, container, listener)
s.waitContainer(container, listener)
}
return nil
},
Expand Down
6 changes: 3 additions & 3 deletions local/compose/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ func (s *composeService) Start(ctx context.Context, project *types.Project, opti
for _, c := range containers {
c := c
go func() {
s.waitContainer(ctx, c, options.Attach)
s.waitContainer(c, options.Attach)
}()
}
return nil
}

func (s *composeService) waitContainer(ctx context.Context, c moby.Container, listener compose.ContainerEventListener) {
statusC, errC := s.apiClient.ContainerWait(ctx, c.ID, container.WaitConditionNotRunning)
func (s *composeService) waitContainer(c moby.Container, listener compose.ContainerEventListener) {
statusC, errC := s.apiClient.ContainerWait(context.Background(), c.ID, container.WaitConditionNotRunning)
name := getContainerNameWithoutProject(c)
select {
case status := <-statusC:
Expand Down

0 comments on commit 9af5ea4

Please sign in to comment.