Module: Polytrix::Command::RunAction
Overview
Common module to execute a Polytrix action such as create, converge, etc.
Instance Method Summary collapse
-
#run_action(_action, scenarios, *_args) ⇒ Object
Run an instance action (create, converge, setup, verify, destroy) on a collection of scenarios.
Instance Method Details
#run_action(_action, scenarios, *_args) ⇒ Object
Run an instance action (create, converge, setup, verify, destroy) on a collection of scenarios. The instance actions will take place in a seperate thread of execution which may or may not be running concurrently.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/polytrix/command.rb', line 104 def run_action(_action, scenarios, *_args) concurrency = 1 if [:concurrency] concurrency = [:concurrency] || scenarios.size concurrency = scenarios.size if concurrency > scenarios.size end scenarios.each { |i| @queue << i } concurrency.times { @queue << nil } threads = concurrency.times.map { |i| spawn(i) } threads.map do |t| begin t.join rescue Polytrix::ExecutionError, Polytrix::ChallengeFailure # respawn thread t.kill threads.delete(t) threads.push(spawn) end end while threads.any?(&:alive?) end |