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

Commit

Permalink
stop as all registered containers exited || cascadestop
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Feb 12, 2021
1 parent 22bfab4 commit 337a0ec
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions cli/cmd/compose/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,26 +263,35 @@ type printer struct {

func (p printer) run(ctx context.Context, cascadeStop bool, exitCodeFrom string, consumer compose.LogConsumer, stopFn func() error) (int, error) { //nolint:unparam
var aborting bool
var count int
for {
event := <-p.queue
switch event.Type {
case compose.ContainerEventAttach:
consumer.Register(event.Service, event.Source)
count++
case compose.ContainerEventExit:
if !aborting {
consumer.Status(event.Service, event.Source, fmt.Sprintf("exited with code %d", event.ExitCode))
}
if cascadeStop && !aborting {
aborting = true
fmt.Println("Aborting on container exit...")
err := stopFn()
if err != nil {
return 0, err
if cascadeStop {
if !aborting {
aborting = true
fmt.Println("Aborting on container exit...")
err := stopFn()
if err != nil {
return 0, err
}
}
if exitCodeFrom == "" || exitCodeFrom == event.Service {
logrus.Error(event.ExitCode)
return event.ExitCode, nil
}
}
if exitCodeFrom == "" || exitCodeFrom == event.Service {
logrus.Error(event.ExitCode)
return event.ExitCode, nil
count--
if count == 0 {
// Last container terminated, done
return 0, nil
}
case compose.ContainerEventLog:
if !aborting {
Expand Down

0 comments on commit 337a0ec

Please sign in to comment.