From b5f153a1a2371ec8bcd239eec185d1d2cf723ef9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 12 Mar 2014 21:34:33 -0700 Subject: [PATCH] command/build: -parallel=false to disable parallelization [GH-924] --- CHANGELOG.md | 2 ++ command/build/command.go | 7 +++++++ command/build/help.go | 1 + 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 018db7977..0367c6dc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ FEATURES: IMPROVEMENTS: * builder/vmware: Workstation 10 support for Linux. [GH-900] +* command/build: Added '-parallel' flag so you can disable parallelization + with `-no-parallel`. [GH-924] BUG FIXES: diff --git a/command/build/command.go b/command/build/command.go index bc0567b41..2b3ceb394 100644 --- a/command/build/command.go +++ b/command/build/command.go @@ -23,12 +23,14 @@ func (Command) Help() string { func (c Command) Run(env packer.Environment, args []string) int { var cfgDebug bool var cfgForce bool + var cfgParallel bool buildOptions := new(cmdcommon.BuildOptions) cmdFlags := flag.NewFlagSet("build", flag.ContinueOnError) cmdFlags.Usage = func() { env.Ui().Say(c.Help()) } cmdFlags.BoolVar(&cfgDebug, "debug", false, "debug mode for builds") cmdFlags.BoolVar(&cfgForce, "force", false, "force a build if artifacts exist") + cmdFlags.BoolVar(&cfgParallel, "parallel", true, "enable/disable parallelization") cmdcommon.BuildOptionFlags(cmdFlags, buildOptions) if err := cmdFlags.Parse(args); err != nil { return 1 @@ -176,6 +178,11 @@ func (c Command) Run(env packer.Environment, args []string) int { wg.Wait() } + if !cfgParallel { + log.Printf("Parallelization disabled, waiting for build to finish: %s", b.Name()) + wg.Wait() + } + if interrupted { log.Println("Interrupted, not going to start any more builds.") break diff --git a/command/build/help.go b/command/build/help.go index 65ec5eb65..5b27a53ad 100644 --- a/command/build/help.go +++ b/command/build/help.go @@ -13,6 +13,7 @@ Options: -machine-readable Machine-readable output -except=foo,bar,baz Build all builds other than these -only=foo,bar,baz Only build the given builds by name + -parallel=false Disable parallelization (on by default) -var 'key=value' Variable for templates, can be used multiple times. -var-file=path JSON file containing user variables. `