Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Kill on second SIGTERM
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Mar 22, 2021
1 parent 9af5ea4 commit 29b5eab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cli/cmd/compose/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,26 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
queue: queue,
}

signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
stopFunc := func() error {
ctx := context.Background()
_, err := progress.Run(ctx, func(ctx context.Context) (string, error) {
go func() {
<-signalChan
c.ComposeService().Kill(ctx, project, compose.KillOptions{})
}()

return "", c.ComposeService().Stop(ctx, project, compose.StopOptions{})
})
return err
}
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-signalChan
queue <- compose.ContainerEvent{
Type: compose.UserCancel,
}
fmt.Println("Gracefully stopping...")
fmt.Println("Gracefully stopping... (press Ctrl+C again to force)")
stopFunc() // nolint:errcheck
}()

Expand Down

0 comments on commit 29b5eab

Please sign in to comment.