module Algae

Constants

VERSION

Public Class Methods

rolling_deploy(asg_name, launch_config=false) click to toggle source
# 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