lib/percheron/actions/start.rb in percheron-0.6.3 vs lib/percheron/actions/start.rb in percheron-0.6.4
- old
+ new
@@ -2,28 +2,35 @@
module Actions
class Start
include Base
- def initialize(container, dependant_containers=[])
+ def initialize(container, dependant_containers: [], exec_scripts: true)
@container = container
@dependant_containers = dependant_containers
+ @exec_scripts = exec_scripts
end
def execute!
- create! unless container.exists?
+ results = []
+ results << create! unless container.exists?
unless container.running?
- start!
- execute_post_start_scripts! unless container.post_start_scripts.empty?
+ results << start!
+ results << execute_post_start_scripts! if exec_scripts?
end
- container
+ results.compact.empty? ? nil : container
end
private
- attr_reader :container, :dependant_containers
+ attr_reader :container, :dependant_containers, :exec_scripts
+ def exec_scripts?
+ !container.post_start_scripts.empty? && exec_scripts
+ end
+
def create!
+ $logger.info "Creating '#{container.name}' container as it doesn't exist"
Create.new(container).execute!
end
def start!
$logger.info "Starting '#{container.name}' container"