Class: EbDeployer::DeploymentStrategy::BlueGreen

Inherits:
Object
  • Object
show all
Defined in:
lib/eb_deployer/deployment_strategy/blue_green.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ BlueGreen

Returns a new instance of BlueGreen.



4
5
6
# File 'lib/eb_deployer/deployment_strategy/blue_green.rb', line 4

def initialize(env)
  @env = env
end

Instance Method Details

#deploy(version_label, env_settings, inactive_settings = []) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/eb_deployer/deployment_strategy/blue_green.rb', line 8

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