Class: Ufo::Cfn::Deploy
- Inherits:
-
Base
- Object
- Ufo::CLI::Base
- Base
- Ufo::Cfn::Deploy
- Defined in:
- lib/ufo/cfn/deploy.rb
Instance Attribute Summary
Attributes inherited from Ufo::CLI::Base
Instance Method Summary collapse
- #ecs_clusters ⇒ Object
- #ensure_cluster_exist ⇒ Object
- #ensure_log_group_exist ⇒ Object
- #run ⇒ Object
-
#stop_old_tasks ⇒ Object
Start a thread that will poll for ecs deployments and kill of tasks in old deployments.
Methods included from Ufo::Concerns
Methods included from Ufo::Concerns::Names
Methods included from AwsServices
#acm, #applicationautoscaling, #aws_options, #cfn, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #s3, #ssm_client, #waf_client
Methods included from AwsServices::Concerns
#find_stack, #find_stack_resources, #stack_resources, #status, #task_definition_arns
Methods inherited from Ufo::CLI::Base
Methods included from Utils::Sure
Methods included from Utils::Pretty
#pretty_home, #pretty_path, #pretty_time
Methods included from Utils::Logging
Constructor Details
This class inherits a constructor from Ufo::CLI::Base
Instance Method Details
#ecs_clusters ⇒ Object
30 31 32 |
# File 'lib/ufo/cfn/deploy.rb', line 30 def ecs_clusters ecs.describe_clusters(clusters: [@cluster]).clusters end |
#ensure_cluster_exist ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ufo/cfn/deploy.rb', line 19 def ensure_cluster_exist return unless Ufo.config.ecs.create_cluster cluster = ecs_clusters.first exist = cluster && cluster.status == "ACTIVE" return if exist ecs.create_cluster(cluster_name: @cluster) logger.info "#{@cluster} cluster created." end |
#ensure_log_group_exist ⇒ Object
50 51 52 |
# File 'lib/ufo/cfn/deploy.rb', line 50 def ensure_log_group_exist Ufo::LogGroup.new(@options).create end |
#run ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ufo/cfn/deploy.rb', line 3 def run ensure_log_group_exist ensure_cluster_exist stop_old_tasks stack = Stack.new(@options) success = stack.deploy return unless @options[:wait] if success puts "Software shipped!" else puts "Software fail to ship." exit 1 end end |
#stop_old_tasks ⇒ Object
Start a thread that will poll for ecs deployments and kill of tasks in old deployments. This must be done in a thread because the stack update process is blocking.
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ufo/cfn/deploy.rb', line 36 def stop_old_tasks return unless @options[:stop_old_tasks] return unless @options[:wait] # only works when deployment is blocking Thread.new do stop = Ufo::Stop.new(@options.merge(mute: true)) while true stop.log "checking for old tasks and waiting for 10 seconds" stop.run sleep 10 end end end |