lib/terraspace/all/runner.rb in terraspace-1.1.2 vs lib/terraspace/all/runner.rb in terraspace-1.1.3

- old
+ new

@@ -39,22 +39,31 @@ def deploy_batch(batch) @pids = {} # stores child processes pids. map of pid to mod_name, reset this list on each batch run concurrency = Terraspace.config.all.concurrency batch.sort_by(&:name).each_slice(concurrency) do |slice| slice.each do |node| - pid = fork do - build_stack(node.name) - run_terraspace(node.name) + if fork? + pid = fork do + deploy_stack(node) + end + @pids[pid] = node.name # store mod_name mapping + else + deploy_stack(node) end - @pids[pid] = node.name # store mod_name mapping end end + return unless fork? wait_for_child_proccess summarize # also reports lower-level error info report_errors # reports finall errors and possibly exit end + def deploy_stack(node) + build_stack(node.name) + run_terraspace(node.name) + end + def build_modules builder = Terraspace::Builder.new(@options.merge(mod: "placeholder", clean: true, quiet: true, include_stacks: :none)) builder.build(modules: true) end @@ -107,11 +116,11 @@ Summary.new(data).run if File.exist?(data[:log_path]) end end def run_terraspace(mod_name) - set_log_path!(mod_name) + set_log_path!(mod_name) if fork? name = command_map(@command) o = @options.merge(mod: mod_name, yes: true, build: false, input: false, log_to_stderr: true) o.merge!(quiet: false) if @command == "init" # noisy so can filter and summarize output case @command when "up" @@ -119,9 +128,13 @@ when "down" Terraspace::CLI::Down.new(o).run else Terraspace::CLI::Commander.new(name, o).run end + end + + def fork? + Terraspace.config.all.concurrency > 1 end def set_log_path!(mod_name) command = terraspace_command(mod_name) path = log_path(mod_name)