浏览代码

Stop displaying logs when user cancels compose up, to not mix with stop progress display

Signed-off-by: Guillaume Tardif <[email protected]>
Guillaume Tardif 4 年之前
父节点
当前提交
3778b664af
共有 2 个文件被更改,包括 7 次插入0 次删除
  1. 2 0
      api/compose/api.go
  2. 5 0
      cli/cmd/compose/up.go

+ 2 - 0
api/compose/api.go

@@ -266,4 +266,6 @@ const (
 	ContainerEventAttach
 	// ContainerEventExit is a ContainerEvent of type exit. ExitCode is set
 	ContainerEventExit
+	// UserCancel user cancelled compose up, we are stopping containers
+	UserCancel
 )

+ 5 - 0
cli/cmd/compose/up.go

@@ -205,6 +205,9 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
 	signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
 	go func() {
 		<-signalChan
+		queue <- compose.ContainerEvent{
+			Type: compose.UserCancel,
+		}
 		fmt.Println("Gracefully stopping...")
 		stopFunc() // nolint:errcheck
 	}()
@@ -332,6 +335,8 @@ func (p printer) run(ctx context.Context, cascadeStop bool, exitCodeFrom string,
 	for {
 		event := <-p.queue
 		switch event.Type {
+		case compose.UserCancel:
+			aborting = true
 		case compose.ContainerEventAttach:
 			consumer.Register(event.Name, event.Source)
 			count++