From 1f148244af9bec286467c57453ad1ab9cb80fdb4 Mon Sep 17 00:00:00 2001 From: vyneer Date: Tue, 28 Nov 2023 17:30:25 +0300 Subject: [PATCH] send out a cancel event on SIGINT/SIGTERM Signed-off-by: vyneer --- pkg/compose/up.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/compose/up.go b/pkg/compose/up.go index 4b3428376..6b168e780 100644 --- a/pkg/compose/up.go +++ b/pkg/compose/up.go @@ -64,6 +64,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM) defer close(signalChan) var isTerminated bool + printer := newLogPrinter(options.Start.Attach) doneCh := make(chan bool) eg.Go(func() error { @@ -74,6 +75,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options return nil case <-signalChan: if first { + printer.Cancel() fmt.Fprintln(s.stdinfo(), "Gracefully stopping... (press Ctrl+C again to force)") eg.Go(func() error { err := s.Stop(context.Background(), project.Name, api.StopOptions{ @@ -98,8 +100,6 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options } }) - printer := newLogPrinter(options.Start.Attach) - var exitCode int eg.Go(func() error { code, err := printer.Run(options.Start.CascadeStop, options.Start.ExitCodeFrom, func() error {