Skip to content

Commit

Permalink
send out a cancel event on SIGINT/SIGTERM
Browse files Browse the repository at this point in the history
Signed-off-by: vyneer <[email protected]>
  • Loading branch information
vyneer authored and ndeloof committed Nov 30, 2023
1 parent 9faef4a commit 1f14824
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/compose/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{
Expand All @@ -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 {
Expand Down

0 comments on commit 1f14824

Please sign in to comment.