浏览代码

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

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 4 年之前
父节点
当前提交
4af04b23ec
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      pkg/compose/logs.go

+ 5 - 1
pkg/compose/logs.go

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