Module: Algae

Defined in:
lib/algae.rb,
lib/algae/version.rb

Defined Under Namespace

Classes: Asg

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.rolling_deploy(asg_name, launch_config = false) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/algae.rb', line 8

def rolling_deploy(asg_name, launch_config=false)
  asg = Asg.new(asg_name)

  if launch_config
    # update launch config
  end

  old_instances = asg.instances
  old_desired = asg.desired
  old_elb_in_service = asg.elb_in_service

  asg.desired *= 2

  started = Time.now
  Wait.until_true!(timeout_in_seconds: 1200) do
    sleep 1
    system 'clear'
    puts "Waiting for a new server to come InService in the ELB for #{Time.now - started}"
    asg.display
    asg.elb_in_service.count > old_elb_in_service.count
  end

  asg.desired = old_desired

  started = Time.now
  Wait.until_true!(timeout_in_seconds: 1200) do
    sleep 1
    system 'clear'
    puts "Waiting for the ASG to scale down for #{Time.now - started}"
    remaining_old_in_service = asg.elb_in_service.select do |id|
      old_elb_in_service.include? id
    end
    pp remaining_old_in_service
    remaining_old_in_service.empty?
  end
end