Class: Ufo::Scale
- Inherits:
-
Object
- Object
- Ufo::Scale
- Includes:
- AwsServices, Defaults
- Defined in:
- lib/ufo/scale.rb
Instance Method Summary collapse
-
#initialize(service, count, options = {}) ⇒ Scale
constructor
A new instance of Scale.
- #service_exists? ⇒ Boolean
- #update ⇒ Object
Methods included from AwsServices
Methods included from Defaults
#default_cluster, #default_desired_count, #default_maximum_percent, #default_minimum_healthy_percent, #new_service_settings, #settings
Constructor Details
#initialize(service, count, options = {}) ⇒ Scale
Returns a new instance of Scale.
6 7 8 9 10 11 |
# File 'lib/ufo/scale.rb', line 6 def initialize(service, count, ={}) @service = service @count = count @options = @cluster = @options[:cluster] || default_cluster end |
Instance Method Details
#service_exists? ⇒ Boolean
27 28 29 30 31 32 |
# File 'lib/ufo/scale.rb', line 27 def service_exists? cluster = ecs.describe_clusters(clusters: [@cluster]).clusters.first return false unless cluster service = ecs.describe_services(services: [@service], cluster: @cluster).services.first !!service end |
#update ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ufo/scale.rb', line 13 def update unless service_exists? puts "Unable to find the #{@service} service on #{@cluster} cluster." puts "Are you sure you are trying to scale the right service on the right cluster?" exit end ecs.update_service( service: @service, cluster: @cluster, desired_count: @count ) puts "Scale #{@service} service in #{@cluster} cluster to #{@count}" unless @options[:mute] end |