Class: Ufo::Task
- Inherits:
-
Object
- Object
- Ufo::Task
- Extended by:
- Memoist
- Includes:
- AwsService, Util
- Defined in:
- lib/ufo/task.rb
Instance Method Summary collapse
-
#initialize(task_definition, options) ⇒ Task
constructor
A new instance of Task.
- #run ⇒ Object
- #run_task(options) ⇒ Object
Methods included from AwsService
#cloudwatchlogs, #ecr, #ecs, #elb
Methods included from Util
#default_cluster, #default_params, #display_params, #execute, #pretty_time, #settings
Constructor Details
#initialize(task_definition, options) ⇒ Task
Returns a new instance of Task.
10 11 12 13 14 |
# File 'lib/ufo/task.rb', line 10 def initialize(task_definition, ) @task_definition = task_definition @options = @cluster = @options[:cluster] || default_cluster end |
Instance Method Details
#run ⇒ Object
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 44 |
# File 'lib/ufo/task.rb', line 16 def run puts "Running task_definition: #{@task_definition}".colorize(:green) unless @options[:mute] return if @options[:noop] = { cluster: @cluster, task_definition: @task_definition } = .merge(default_params[:run_task] || {}) if @options[:command] .merge!(overrides: overrides) puts "Running task with container overrides." puts "Command: #{@options[:command].join(' ')}" end unless @options[:mute] puts "Running task with params:" display_params() end resp = run_task() unless @options[:mute] task_arn = resp.tasks[0].task_arn puts "Task ARN: #{task_arn}" puts " aws ecs describe-tasks --tasks #{task_arn} --cluster #{@cluster}" cloudwatch_info(task_arn) end end |
#run_task(options) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ufo/task.rb', line 46 def run_task() ecs.run_task() rescue Aws::ECS::Errors::ClientException => e if e. =~ /ECS was unable to assume the role/ puts "ERROR: #{e.class} #{e.}".colorize(:red) puts "Please double check the executionRoleArn in your task definition." exit 1 else raise end end |