From 3778b664af7113d3448d1ef6658a8176f34f09e0 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Tue, 23 Feb 2021 15:13:51 +0100 Subject: [PATCH] Stop displaying logs when user cancels compose up, to not mix with stop progress display Signed-off-by: Guillaume Tardif --- api/compose/api.go | 2 ++ cli/cmd/compose/up.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/api/compose/api.go b/api/compose/api.go index 2c927d6ca..c68b5e93b 100644 --- a/api/compose/api.go +++ b/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 ) diff --git a/cli/cmd/compose/up.go b/cli/cmd/compose/up.go index 2cff80c49..1a2dd54e8 100644 --- a/cli/cmd/compose/up.go +++ b/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++