Sha256: 503ffcd1fb8191b87f36ee536460970516e8741fd6b37918836c8c873d3e960d

Contents?: true

Size: 1.14 KB

Versions: 16

Compression:

Stored size: 1.14 KB

Contents

module EbDeployer
  module DeploymentStrategy
    class BlueGreen
      def initialize(env)
        @env = env
      end

      def deploy(version_label, env_settings, inactive_settings=[])
        if !ebenvs.any?(&method(:active_ebenv?))
          ebenv('a', @env.cname_prefix).
            deploy(version_label, env_settings)
          return
        end

        active_ebenv = ebenvs.detect(&method(:active_ebenv?))
        inactive_ebenv = ebenvs.reject(&method(:active_ebenv?)).first

        inactive_ebenv.deploy(version_label, env_settings)
        active_ebenv.swap_cname_with(inactive_ebenv)
        unless inactive_settings.empty?
          active_ebenv.log("applying inactive settings...")
          active_ebenv.apply_settings(inactive_settings)
        end
      end

      private
      def active_ebenv?(ebenv)
        ebenv.cname_prefix == @env.cname_prefix
      end

      def ebenvs
        [ebenv('a'), ebenv('b')]
      end

      def ebenv(suffix, cname_prefix=nil)
        @env.new_eb_env(suffix, cname_prefix || inactive_cname_prefix)
      end

      def inactive_cname_prefix
        "#{@env.cname_prefix}-inactive"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
eb_deployer-0.4.13 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.12 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.11 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.10 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.9 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.8 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.7.beta1 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.6 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.5 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.4 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.4.beta7 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.4.beta6 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.4.beta5 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.4.beta4 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.4.beta3 lib/eb_deployer/deployment_strategy/blue_green.rb
eb_deployer-0.4.4.beta2 lib/eb_deployer/deployment_strategy/blue_green.rb