elastic_beans 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '058ffb4aa22e205e19470449420643bc3e55298f'
4
- data.tar.gz: 5dcd342a6962c0ee82dd672c2ee07a32fc7b1562
3
+ metadata.gz: eaa8b4c3e65d502798c78492a575fd8f2977b5ef
4
+ data.tar.gz: 4f01b3ca52c88736e1d9c38ac0cfae93e13a65f2
5
5
  SHA512:
6
- metadata.gz: 40f88906d991227878c85386c3fd79fba38e14bbddddfbb26c9101e3c4b1e01d7996f9dafef8cb1b0e3035f59548a664f41c4de94f46d0010a7bd9b653c517d8
7
- data.tar.gz: 3aeebfe162e590b106c6e253af178aef7c447ef4d005179ed197e34c4357a5a350bcc864a1e8eed51ef9c1d9e425a6617fe6a06df4a540e2b7aea8470f79829c
6
+ metadata.gz: f7b3adc0fd44ad475de17d6c846ff5cace585ed29a07715676bd31509f75f4cc44c7284e0ca88660ebbf7724ec0ca7dccc79a3d81ed1a55278a40025766ea52f
7
+ data.tar.gz: 5f248ed95c125b1bde81186bf6d69157cb52129ea376dcf8618904a3b3ac33a301707ac219e559847ec875b4e99b1a3f7a379aedff264e94dd619ea87f735beb
@@ -113,6 +113,24 @@ class ElasticBeans::CLI < Thor
113
113
  error(e)
114
114
  end
115
115
 
116
+ desc ElasticBeans::Command::Restart::USAGE, ElasticBeans::Command::Restart::DESC
117
+ long_desc ElasticBeans::Command::Restart::LONG_DESC
118
+ option :application, aliases: %w(-a), required: true, desc: APPLICATION_DESC
119
+ option :queue, aliases: %w(-q), desc: "The name of the queue to identify the worker environment to restart, e.g. `default`"
120
+ def restart(environment = nil)
121
+ @verbose = options[:verbose]
122
+ ElasticBeans::Command::Restart.new(
123
+ application: application(
124
+ name: options[:application],
125
+ ),
126
+ queue: options[:queue],
127
+ elastic_beanstalk: elastic_beanstalk_client,
128
+ ui: ui,
129
+ ).run(environment)
130
+ rescue StandardError => e
131
+ error(e)
132
+ end
133
+
116
134
  desc ElasticBeans::Command::Scale::USAGE, ElasticBeans::Command::Scale::DESC
117
135
  long_desc ElasticBeans::Command::Scale::LONG_DESC
118
136
  option :application, aliases: %w(-a), required: true, desc: APPLICATION_DESC
@@ -3,6 +3,7 @@ require "elastic_beans/command/create"
3
3
  require "elastic_beans/command/deploy"
4
4
  require "elastic_beans/command/exec"
5
5
  require "elastic_beans/command/ps"
6
+ require "elastic_beans/command/restart"
6
7
  require "elastic_beans/command/scale"
7
8
  require "elastic_beans/command/get_env"
8
9
  require "elastic_beans/command/set_env"
@@ -13,6 +13,7 @@ module ElasticBeans
13
13
  LONG_DESC = <<-LONG_DESC
14
14
  Create a new environment in Elastic Beanstalk and attach it to relevant resources.
15
15
  The environment type must be one of the recognized types: webserver, worker, exec, or scheduled.
16
+ Use `-q` for worker environments to clarify which worker environment to create, e.g. `create worker -q default`.
16
17
 
17
18
  A new environment will use the same deployed version as all other environments.
18
19
  If this is the first environment, a new version will be created from the HEAD git commit of the working directory.
@@ -0,0 +1,88 @@
1
+ require "ruby-progressbar"
2
+ require "elastic_beans/error"
3
+ require "elastic_beans/error/environments_not_ready"
4
+
5
+ module ElasticBeans
6
+ module Command
7
+ # :nodoc: all
8
+ class Restart
9
+ USAGE = "restart [ENVIRONMENT]"
10
+ DESC = "Restart one or all environments in the Elastic Beanstalk application"
11
+ LONG_DESC = <<-LONG_DESC
12
+ Given no arguments, restarts all servers for the application.
13
+ Given an environment name, restarts only the servers for that environment, e.g. `restart webserver`.
14
+ Use `-q` for worker environments to clarify which worker environment to restart, e.g. `restart worker -q default`.
15
+
16
+ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
17
+ LONG_DESC
18
+
19
+ def initialize(application:, queue:, elastic_beanstalk:, ui:)
20
+ @application = application
21
+ @queue = queue
22
+ @elastic_beanstalk = elastic_beanstalk
23
+ @ui = ui
24
+ end
25
+
26
+ def run(environment_type = nil)
27
+ environments = []
28
+ if environment_type
29
+ environment = ElasticBeans::Environment.new_by_type(
30
+ environment_type,
31
+ queue: queue,
32
+ application: application,
33
+ elastic_beanstalk: elastic_beanstalk,
34
+ )
35
+ environments << environment
36
+ if environment.status != "Ready"
37
+ raise EnvironmentsNotReady.new(environments: environments)
38
+ end
39
+ else
40
+ environments = application.environments
41
+ if environments.empty?
42
+ raise NoEnvironmentsError
43
+ end
44
+ unready_environments = environments.select { |environment| environment.status != "Ready" }
45
+ if unready_environments.any?
46
+ raise EnvironmentsNotReady.new(environments: unready_environments)
47
+ end
48
+ end
49
+
50
+ progressbar = ProgressBar.create(title: "Restarting", total: nil, output: ui.stdout)
51
+
52
+ threads = environments.map { |environment|
53
+ progressbar.log("Restarting `#{environment.name}'...")
54
+ thread = Thread.new do
55
+ environment.restart
56
+ end
57
+ progressbar.increment
58
+ thread
59
+ }
60
+
61
+ loop do
62
+ sleep 0.5
63
+ progressbar.increment
64
+ if threads.none?(&:alive?)
65
+ progressbar.total = progressbar.progress
66
+ break
67
+ end
68
+ end
69
+
70
+ threads.each(&:join)
71
+ end
72
+
73
+ private
74
+
75
+ attr_reader :application, :queue, :elastic_beanstalk, :ui
76
+
77
+ class NoEnvironmentsError < ElasticBeans::Error
78
+ def message
79
+ <<-MESSAGE
80
+ There are no environments to restart! Please create some using `beans create`.
81
+
82
+ #{command_help "create"}
83
+ MESSAGE
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -9,6 +9,7 @@ module ElasticBeans
9
9
  DESC = "Change the autoscaling minimum and maximum for the given environment"
10
10
  LONG_DESC = <<-LONG_DESC
11
11
  Change the autoscaling minimum and maximum for the given environment.
12
+ Use `-q` for worker environments to clarify which worker environment to scale, e.g. `scale worker -q default -i 1 -m 2`.
12
13
 
13
14
  Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
14
15
  LONG_DESC
@@ -157,6 +157,8 @@ module ElasticBeans
157
157
  rescue ::Aws::ElasticBeanstalk::Errors::Throttling
158
158
  sleep 5
159
159
  retry
160
+ rescue ::Aws::ElasticBeanstalk::Errors::InvalidParameterValue
161
+ raise MissingEnvironmentError.new(environment: self, application: application)
160
162
  end
161
163
 
162
164
  # Updates the environment configuration to change the minimum and maximum size of the autoscaling group.
@@ -1,3 +1,3 @@
1
1
  module ElasticBeans
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_beans
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Stegman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-06 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -183,6 +183,7 @@ files:
183
183
  - lib/elastic_beans/command/exec.rb
184
184
  - lib/elastic_beans/command/get_env.rb
185
185
  - lib/elastic_beans/command/ps.rb
186
+ - lib/elastic_beans/command/restart.rb
186
187
  - lib/elastic_beans/command/scale.rb
187
188
  - lib/elastic_beans/command/set_env.rb
188
189
  - lib/elastic_beans/command/talk.rb