add support for COMPOSE_PARALLEL_LIMIT (parity with Compose v1)

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2023-01-04 12:41:36 +01:00
parent b96e27e0e7
commit aa5cdf2bf9
1 changed files with 8 additions and 0 deletions

View File

@ -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)
}