module MultiEc2Kiq

Constants

VERSION

Attributes

config_path[RW]

Public Instance Methods

create_status_table() click to toggle source
# File lib/multi_ec2_kiq.rb, line 25
def create_status_table
  Settings.source(config_path)
  Dynamodb.new.create_status_table
end
start() click to toggle source
# File lib/multi_ec2_kiq.rb, line 8
def start
  Settings.source(config_path)
  instances = Settings.instances
  threads = []

  instances.each {|instance| settings_check(instance)}
  instances.each {|instance|
    threads << Thread.new do
      ec2_start(instance)
    end
  }

  threads.each { |t| t.join }

  true
end
start_wait_until_stop() click to toggle source
# File lib/multi_ec2_kiq.rb, line 30
def start_wait_until_stop
  Settings.source(config_path)
  instances = Settings.instances
  threads = []

  instances.each {|instance| settings_check(instance)}
  instances.each {|instance|
    threads << Thread.new do
      ec2_start_wait_until_stop(instance)
    end
  }

  threads.each { |t| t.join }

  true
end

Private Instance Methods

ec2_start(instance) click to toggle source
# File lib/multi_ec2_kiq.rb, line 54
def ec2_start(instance)
  Ec2.new(instance["id"], instance["region"]).start
end
ec2_start_wait_until_stop(instance) click to toggle source
# File lib/multi_ec2_kiq.rb, line 58
def ec2_start_wait_until_stop(instance)
  Ec2.new(instance["id"], instance["region"]).start_wait_until_stop
end
settings_check(e) click to toggle source
# File lib/multi_ec2_kiq.rb, line 49
def settings_check(e)
  raise "instance_configs requires id." if !e.has_key?("id")
  raise "instance_configs requires region." if !e.has_key?("region")
end