Sha256: d939f011ebf424c2c13a1a13bc69daba437ad79bd271d711583d99b093f280e5

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Percheron
  module Actions
    class Start

      include Base

      def initialize(container, dependant_containers=[])
        @container = container
        @dependant_containers = dependant_containers
      end

      def execute!
        create_or_recreate!
        unless container.running?
          start!
          execute_post_start_scripts! unless container.post_start_scripts.empty?
        end
        container
      end

      private

        attr_reader :container, :dependant_containers

        def create_or_recreate!
          container.exists? ? recreate! : create!
        end

        def create!
          Create.new(container).execute!
        end

        def recreate!
          Recreate.new(container).execute!
        end

        def start!
          $logger.info "Starting '#{container.name}' container"
          container.docker_container.start!
        end

        def execute_post_start_scripts!
          Exec.new(container, dependant_containers, container.post_start_scripts, 'POST start').execute!
        end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
percheron-0.6.2 lib/percheron/actions/start.rb