lib/bolt/executor.rb in bolt-0.6.1 vs lib/bolt/executor.rb in bolt-0.7.0
- old
+ new
@@ -1,13 +1,19 @@
+require 'logger'
require 'concurrent'
require 'bolt/result'
require 'bolt/config'
+require 'bolt/formatter'
module Bolt
class Executor
def initialize(config = Bolt::Config.new)
@config = config
+ @logger = Logger.new(config[:log_destination])
+ @logger.progname = 'executor'
+ @logger.level = config[:log_level]
+ @logger.formatter = Bolt::Formatter.new
end
def from_uris(nodes)
nodes.map do |node|
Bolt::Node.from_uri(node, config: @config)
@@ -17,10 +23,16 @@
def on(nodes)
results = Concurrent::Map.new
poolsize = [nodes.length, @config[:concurrency]].min
pool = Concurrent::FixedThreadPool.new(poolsize)
+ @logger.debug { "Started with #{poolsize} thread(s)" }
+
+ nodes.map(&:class).uniq.each do |klass|
+ klass.initialize_transport(@logger)
+ end
+
nodes.each { |node|
pool.post do
results[node] =
begin
node.connect
@@ -45,12 +57,12 @@
on(nodes) do |node|
node.run_command(command)
end
end
- def run_script(nodes, script)
+ def run_script(nodes, script, arguments)
on(nodes) do |node|
- node.run_script(script)
+ node.run_script(script, arguments)
end
end
def run_task(nodes, task, input_method, arguments)
on(nodes) do |node|