Class: ElasticBeans::Command::Scale

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_beans/command/scale.rb

Overview

:nodoc: all

Constant Summary collapse

USAGE =
"scale ENVIRONMENT_TYPE"
DESC =
"Change the autoscaling minimum and maximum for the given environment"
LONG_DESC =
<<-LONG_DESC
Change the autoscaling minimum and maximum for the given environment.
Use `-q` for worker environments to clarify which worker environment to scale, e.g. `scale worker -q default -i 1 -m 2`.

Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
LONG_DESC

Instance Method Summary collapse

Constructor Details

#initialize(application:, minimum:, maximum:, queue:, elastic_beanstalk:, ui:) ⇒ Scale

Returns a new instance of Scale.



17
18
19
20
21
22
23
24
# File 'lib/elastic_beans/command/scale.rb', line 17

def initialize(application:, minimum:, maximum:, queue:, elastic_beanstalk:, ui:)
  @application = application
  @minimum = minimum
  @maximum = maximum
  @queue = queue
  @elastic_beanstalk = elastic_beanstalk
  @ui = ui
end

Instance Method Details

#run(environment_type) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/elastic_beans/command/scale.rb', line 26

def run(environment_type)
  environment = ElasticBeans::Environment.new_by_type(
    environment_type,
    queue: queue,
    application: application,
    elastic_beanstalk: elastic_beanstalk,
  )
  if environment.status != "Ready"
    raise EnvironmentsNotReady.new(environments: [environment])
  end

  config = ElasticBeans::ConfigurationTemplate.new_by_type(
    environment_type,
    queue: queue,
    application: application,
    elastic_beanstalk: elastic_beanstalk,
  )

  progressbar = ProgressBar.create(title: "Configuring", total: nil, output: ui.stdout)
  update_configuration(config, progressbar: progressbar)
  scale_environment(environment, progressbar: progressbar)

  clean_up_enqueued_commands(environment: environment) if environment_type == "exec"
end