Sha256: 269cff06717b7eafcd825f4569a8dda9236e85fbaf8c3cc663caccfa2d4f18ca

Contents?: true

Size: 1.05 KB

Versions: 2

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!
        start!                        unless container.running?
        execute_post_start_scripts!   unless container.post_start_scripts.empty?
        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

2 entries across 2 versions & 1 rubygems

Version Path
percheron-0.6.1 lib/percheron/actions/start.rb
percheron-0.6.0 lib/percheron/actions/start.rb