`log --follow` must stop when container get killed

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-10-01 14:13:51 +02:00
parent 0a81a98b7d
commit 4af04b23ec
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 5 additions and 1 deletions

View File

@ -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 {