Browse Source

add support for COMPOSE_PARALLEL_LIMIT (parity with Compose v1)

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 2 years ago
parent
commit
aa5cdf2bf9
1 changed files with 8 additions and 0 deletions
  1. 8 0
      cmd/compose/compose.go

+ 8 - 0
cmd/compose/compose.go

@@ -22,6 +22,7 @@ import (
 	"os"
 	"os/signal"
 	"path/filepath"
+	"strconv"
 	"strings"
 	"syscall"
 
@@ -324,6 +325,13 @@ func RootCommand(streams api.Streams, backend api.Service) *cobra.Command { //no
 					return err
 				}
 			}
+			if v, ok := os.LookupEnv("COMPOSE_PARALLEL_LIMIT"); ok && !cmd.Flags().Changed("parallel") {
+				i, err := strconv.Atoi(v)
+				if err != nil {
+					return fmt.Errorf("COMPOSE_PARALLEL_LIMIT must be an integer (found: %q)", v)
+				}
+				parallel = i
+			}
 			if parallel > 0 {
 				backend.MaxConcurrency(parallel)
 			}