send out a cancel event on SIGINT/SIGTERM

Signed-off-by: vyneer <vyn33r@gmail.com>
This commit is contained in:
vyneer 2023-11-28 17:30:25 +03:00 committed by Nicolas De loof
parent 9faef4aebb
commit 1f148244af
1 changed files with 2 additions and 2 deletions

View File

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