mirror of
https://github.com/docker/compose.git
synced 2025-07-24 06:04:57 +02:00
send out a cancel event on SIGINT/SIGTERM
Signed-off-by: vyneer <vyn33r@gmail.com>
This commit is contained in:
parent
9faef4aebb
commit
1f148244af
@ -64,6 +64,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
|
|||||||
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
|
||||||
defer close(signalChan)
|
defer close(signalChan)
|
||||||
var isTerminated bool
|
var isTerminated bool
|
||||||
|
printer := newLogPrinter(options.Start.Attach)
|
||||||
|
|
||||||
doneCh := make(chan bool)
|
doneCh := make(chan bool)
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
@ -74,6 +75,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
|
|||||||
return nil
|
return nil
|
||||||
case <-signalChan:
|
case <-signalChan:
|
||||||
if first {
|
if first {
|
||||||
|
printer.Cancel()
|
||||||
fmt.Fprintln(s.stdinfo(), "Gracefully stopping... (press Ctrl+C again to force)")
|
fmt.Fprintln(s.stdinfo(), "Gracefully stopping... (press Ctrl+C again to force)")
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
err := s.Stop(context.Background(), project.Name, api.StopOptions{
|
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
|
var exitCode int
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
code, err := printer.Run(options.Start.CascadeStop, options.Start.ExitCodeFrom, func() error {
|
code, err := printer.Run(options.Start.CascadeStop, options.Start.ExitCodeFrom, func() error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user