Class: EcsCmd::Service
- Inherits:
-
Object
- Object
- EcsCmd::Service
- Defined in:
- lib/ecs_cmd/service.rb
Instance Method Summary collapse
- #arn ⇒ Object
- #deployment_configuration ⇒ Object
- #deployments ⇒ Object
- #desired_count ⇒ Object
- #events ⇒ Object
- #health_check_grace_period ⇒ Object
-
#initialize(cluster, name, region) ⇒ Service
constructor
A new instance of Service.
- #list_service ⇒ Object
- #name ⇒ Object
- #pending_count ⇒ Object
- #running_count ⇒ Object
- #status ⇒ Object
- #task_definition ⇒ Object
Constructor Details
#initialize(cluster, name, region) ⇒ Service
Returns a new instance of Service.
6 7 8 9 10 |
# File 'lib/ecs_cmd/service.rb', line 6 def initialize(cluster, name, region) @client = Aws::ECS::Client.new(region: region) @service_stats = @client.describe_services(cluster: cluster, services: [name])[0] raise 'service does not appear to exist' if @service_stats.empty? end |
Instance Method Details
#arn ⇒ Object
12 13 14 |
# File 'lib/ecs_cmd/service.rb', line 12 def arn @service_stats[0]['service_arn'] end |
#deployment_configuration ⇒ Object
37 38 39 |
# File 'lib/ecs_cmd/service.rb', line 37 def deployment_configuration @service_stats[0]['deployment_configuration'] end |
#deployments ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ecs_cmd/service.rb', line 20 def deployments t = [] @service_stats[0]['deployments'].each do |e| t << ['id', e['id']] t << ['status', e['status']] t << ['task definition', e['task_definition']] t << ['desired count', e['desired_count']] t << ['pending count', e['pending_count']] t << ['running count', e['running_count']] t << ['created at', e['created_at']] t << ['updated at', e['updated_at']] t << ["\n"] end table = Terminal::Table.new headings: ['DEPLOYMENTS'], rows: t table end |
#desired_count ⇒ Object
41 42 43 |
# File 'lib/ecs_cmd/service.rb', line 41 def desired_count @service_stats[0]['desired_count'] end |
#events ⇒ Object
61 62 63 64 65 |
# File 'lib/ecs_cmd/service.rb', line 61 def events @service_stats[0]['events'].each do |e| puts "#{e['created_at']}: #{e['message']}" end end |
#health_check_grace_period ⇒ Object
57 58 59 |
# File 'lib/ecs_cmd/service.rb', line 57 def health_check_grace_period @service_stats[0]['health_check_grace_period_seconds'] end |
#list_service ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ecs_cmd/service.rb', line 71 def list_service row1 = [] row1 << [name, status, running_count, desired_count, pending_count, deployment_configuration['maximum_percent'], deployment_configuration['minimum_healthy_percent']] table1 = Terminal::Table.new headings: ['NAME', 'STATUS', 'RUNNING COUNT', 'DESIRED COUNT', 'PENDING COUNT', 'MAX HEALTHY', 'MIN HEALTHY'], rows: row1 row2 = [] row2 << [task_definition] table2 = Terminal::Table.new headings: ['TASK DEFINITION'], rows: row2 puts table1 puts table2 puts deployments end |
#name ⇒ Object
67 68 69 |
# File 'lib/ecs_cmd/service.rb', line 67 def name @service_stats[0]['service_name'] end |
#pending_count ⇒ Object
49 50 51 |
# File 'lib/ecs_cmd/service.rb', line 49 def pending_count @service_stats[0]['pending_count'] end |
#running_count ⇒ Object
45 46 47 |
# File 'lib/ecs_cmd/service.rb', line 45 def running_count @service_stats[0]['running_count'] end |
#status ⇒ Object
16 17 18 |
# File 'lib/ecs_cmd/service.rb', line 16 def status @service_stats[0]['status'] end |
#task_definition ⇒ Object
53 54 55 |
# File 'lib/ecs_cmd/service.rb', line 53 def task_definition @service_stats[0]['task_definition'] end |