Sha256: 5b7b408cb56ead19ab6b2f7f9188534537d577dbc0c797fc9d55b5f3eb2746fc
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
module Percheron module Actions class Exec include Base def initialize(container, dependant_containers, scripts, description) @container = container @dependant_containers = dependant_containers @scripts = scripts @description = description end def execute! results = [] $logger.debug "Executing #{description} scripts '#{scripts.inspect}' on '#{container.name}'" started_dependant_containers = start_containers!(dependant_containers) results << execute_scripts_on_running_container! results << stop_containers!(started_dependant_containers) results.compact.empty? ? nil : container end private attr_reader :container, :dependant_containers, :scripts, :description def execute_scripts_on_running_container! container_running = container.running? Start.new(container, exec_scripts: false).execute! unless container_running execute_scripts! Stop.new(container).execute! unless container_running end def execute_scripts! scripts.each do |script| in_working_directory(base_dir) do file = Pathname.new(File.expand_path(script, base_dir)) execute_command!('/bin/bash -x /tmp/%s 2>&1' % file.basename) end end end def execute_command!(command) $logger.info "Executing #{description} '#{command}' for '#{container.name}' container" container.docker_container.exec(command.split(' ')) do |device, out| $logger.debug '%s: %s' % [ device, out.strip ] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
percheron-0.6.4 | lib/percheron/actions/exec.rb |