Sha256: 2db77b1c484d6f46b8aa86ed7cc0106e599185a3f7c6c234cdd35645fc123c94
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
module Percheron module Container module Actions class Start include Base def initialize(container) @container = container end def execute! if container.exists? start! execute_post_start_scripts! else raise Errors::ContainerDoesNotExist.new end end private attr_reader :container def start_opts opts = container.ports.inject({}) do |all, p| destination, source = p.split(':') all[source] = [ { 'HostPort' => destination } ] all end { 'PortBindings' => opts, 'Links' => container.links, 'Binds' => container.volumes } end def start! $logger.debug "Starting '#{container.name}'" container.docker_container.start!(start_opts) end def execute_post_start_scripts! container.post_start_scripts.each do |script| in_working_directory(base_dir) do file = Pathname.new(File.expand_path(script, base_dir)) command = '/bin/bash -x /tmp/%s 2>&1' % file.basename $logger.debug "Executing POST create '#{command}' for '#{container.name}' container" container.docker_container.exec(command.split(' ')) end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
percheron-0.5.0 | lib/percheron/container/actions/start.rb |