Skip to content

Commit

Permalink
log --follow must stop when container get killed
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Oct 1, 2021
1 parent 0a81a98 commit d9cf22c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pkg/compose/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ func (s *composeService) Logs(ctx context.Context, projectName string, consumer

eg, ctx := errgroup.WithContext(ctx)
if options.Follow {
printer := newLogPrinter(consumer)
eg.Go(func() error {
printer := newLogPrinter(consumer)
return s.watchContainers(ctx, projectName, options.Services, printer.HandleEvent, containers, func(c types.Container) error {
return s.logContainers(ctx, consumer, c, options)
})
})
eg.Go(func() error {
_, err := printer.Run(false, "", nil)
return err
})
}

for _, c := range containers {
Expand Down
2 changes: 1 addition & 1 deletion pkg/compose/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *composeService) watchContainers(ctx context.Context, projectName string
}
name := getContainerNameWithoutProject(container)

if event.Status == "die" {
if event.Status == "die" || event.Status == "kill"{
restarted := watched[container.ID]
watched[container.ID] = restarted + 1
// Container terminated.
Expand Down

0 comments on commit d9cf22c

Please sign in to comment.