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

Commit a942ef4

Browse files
committed
Kill on second SIGTERM
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 9af5ea4 commit a942ef4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cli/cmd/compose/up.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,21 +274,26 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
274274
queue: queue,
275275
}
276276

277+
signalChan := make(chan os.Signal, 1)
278+
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
277279
stopFunc := func() error {
278280
ctx := context.Background()
279281
_, err := progress.Run(ctx, func(ctx context.Context) (string, error) {
282+
go func() {
283+
<-signalChan
284+
c.ComposeService().Kill(ctx, project, compose.KillOptions{}) // nolint:errcheck
285+
}()
286+
280287
return "", c.ComposeService().Stop(ctx, project, compose.StopOptions{})
281288
})
282289
return err
283290
}
284-
signalChan := make(chan os.Signal, 1)
285-
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
286291
go func() {
287292
<-signalChan
288293
queue <- compose.ContainerEvent{
289294
Type: compose.UserCancel,
290295
}
291-
fmt.Println("Gracefully stopping...")
296+
fmt.Println("Gracefully stopping... (press Ctrl+C again to force)")
292297
stopFunc() // nolint:errcheck
293298
}()
294299

0 commit comments

Comments
 (0)