Class: DeployRunner
- Inherits:
-
Object
- Object
- DeployRunner
- Defined in:
- lib/deployer/deploy_runner.rb
Instance Method Summary collapse
- #deploy(instances) ⇒ Object
- #deploy_instance(instance) ⇒ Object
-
#initialize(strategy) ⇒ DeployRunner
constructor
A new instance of DeployRunner.
- #renew(instance) ⇒ Object
- #run(group_name) ⇒ Object
Constructor Details
#initialize(strategy) ⇒ DeployRunner
Returns a new instance of DeployRunner.
5 6 7 |
# File 'lib/deployer/deploy_runner.rb', line 5 def initialize strategy @strategy = strategy end |
Instance Method Details
#deploy(instances) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/deployer/deploy_runner.rb', line 18 def deploy instances instances.each_with_index do |instance, index| puts "Starting deployment #{index + 1}. Instance #{instance.id}" deploy_instance instance puts "Finished deployment #{index + 1}. Instance #{instance.id}" end end |
#deploy_instance(instance) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/deployer/deploy_runner.rb', line 26 def deploy_instance instance if instance.exists? @strategy.before_instance instance if @strategy.respond_to? :before_instance renew instance @strategy.after_instance instance if @strategy.respond_to? :after_instance else puts "Instance out. Ignored during renew" end end |
#renew(instance) ⇒ Object
36 37 38 39 40 |
# File 'lib/deployer/deploy_runner.rb', line 36 def renew instance puts "Terminating instance #{instance.id}" instance.terminate puts "Instance #{instance.id} sucessfully terminated" end |
#run(group_name) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/deployer/deploy_runner.rb', line 9 def run group_name group = ScaleGroup.new group_name instances = group.instances @strategy.before_group(group) if @strategy.respond_to? :before_group deploy instances @strategy.after_group group if @strategy.respond_to? :after_group end |