mirror of
https://github.com/docker/compose.git
synced 2025-07-22 13:14:29 +02:00
Kill on second SIGTERM
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
9af5ea4b6a
commit
a942ef4a81
@ -274,21 +274,26 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
|
|||||||
queue: queue,
|
queue: queue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signalChan := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
|
||||||
stopFunc := func() error {
|
stopFunc := func() error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
_, err := progress.Run(ctx, func(ctx context.Context) (string, error) {
|
_, err := progress.Run(ctx, func(ctx context.Context) (string, error) {
|
||||||
|
go func() {
|
||||||
|
<-signalChan
|
||||||
|
c.ComposeService().Kill(ctx, project, compose.KillOptions{}) // nolint:errcheck
|
||||||
|
}()
|
||||||
|
|
||||||
return "", c.ComposeService().Stop(ctx, project, compose.StopOptions{})
|
return "", c.ComposeService().Stop(ctx, project, compose.StopOptions{})
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
signalChan := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
|
|
||||||
go func() {
|
go func() {
|
||||||
<-signalChan
|
<-signalChan
|
||||||
queue <- compose.ContainerEvent{
|
queue <- compose.ContainerEvent{
|
||||||
Type: compose.UserCancel,
|
Type: compose.UserCancel,
|
||||||
}
|
}
|
||||||
fmt.Println("Gracefully stopping...")
|
fmt.Println("Gracefully stopping... (press Ctrl+C again to force)")
|
||||||
stopFunc() // nolint:errcheck
|
stopFunc() // nolint:errcheck
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user