capify-ec2 1.4.2.pre4 → 1.4.3.pre5
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +10 -0
- data/lib/capify-ec2/capistrano.rb +1 -1
- data/lib/capify-ec2/version.rb +1 -1
- data/lib/capify-ec2.rb +12 -2
- data/readme.md +27 -1
- metadata +5 -5
data/Changelog.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 1.4.3.pre5 (Apr 9, 2013)
|
2
|
+
|
3
|
+
Features:
|
4
|
+
|
5
|
+
- Allowed the expected result for the rolling deployment healthcheck to be specified as a regex or an array in addition to a string.
|
6
|
+
|
7
|
+
Bugfixes:
|
8
|
+
|
9
|
+
- Fixed an issue which was preventing the main deployment task from being executed during a rolling deployment.
|
10
|
+
|
1
11
|
## 1.4.2.pre4 (Mar 28, 2013)
|
2
12
|
|
3
13
|
Features:
|
@@ -105,7 +105,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
105
105
|
load_balancer_to_reregister = capify_ec2.deregister_instance_from_elb_by_dns(server_dns) if is_load_balanced
|
106
106
|
|
107
107
|
# Call the standard 'cap deploy' task with our redefined role containing a single server.
|
108
|
-
|
108
|
+
top.deploy.default
|
109
109
|
|
110
110
|
server_roles.each do |a_role|
|
111
111
|
|
data/lib/capify-ec2/version.rb
CHANGED
data/lib/capify-ec2.rb
CHANGED
@@ -219,6 +219,16 @@ class CapifyEc2
|
|
219
219
|
end
|
220
220
|
|
221
221
|
def instance_health_by_url(dns, port, path, expected_response, options = {})
|
222
|
+
def response_matches_expected?(response, expected_response)
|
223
|
+
if expected_response.kind_of?(Array)
|
224
|
+
expected_response.any?{ |r| response_matches_expected?(response, r) }
|
225
|
+
elsif expected_response.kind_of?(Regexp)
|
226
|
+
(response =~ expected_response) != nil
|
227
|
+
else
|
228
|
+
response == expected_response
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
222
232
|
protocol = options[:https] ? 'https://' : 'http://'
|
223
233
|
uri = URI("#{protocol}#{dns}:#{port}#{path}")
|
224
234
|
|
@@ -231,7 +241,7 @@ class CapifyEc2
|
|
231
241
|
Timeout::timeout(options[:timeout]) do
|
232
242
|
begin
|
233
243
|
result = http.get(uri.path)
|
234
|
-
raise "Server responded with '#{result.code}: #{result.body}', expected '#{expected_response}'" unless result.body
|
244
|
+
raise "Server responded with '#{result.code}: #{result.body}', expected '#{expected_response}'" unless response_matches_expected?(result.body, expected_response)
|
235
245
|
rescue => e
|
236
246
|
puts "[Capify-EC2] Unexpected response: #{e}..."
|
237
247
|
sleep 1
|
@@ -240,7 +250,7 @@ class CapifyEc2
|
|
240
250
|
end
|
241
251
|
rescue Timeout::Error => e
|
242
252
|
end
|
243
|
-
result ? result.body
|
253
|
+
result ? response_matches_expected?(result.body, expected_response) : false
|
244
254
|
end
|
245
255
|
end
|
246
256
|
|
data/readme.md
CHANGED
@@ -341,7 +341,33 @@ In this example, the following URL would be generated:
|
|
341
341
|
http://EC2_INSTANCE_PUBLIC_DNS_HERE:80/status
|
342
342
|
```
|
343
343
|
|
344
|
-
And the contents of the page at that URL must match 'OK' for the healthcheck to pass. If unsuccessful, the healthcheck is repeated every second, until a timeout of 60 seconds is reached, at which point the rolling deployment is aborted, and a progress summary displayed.
|
344
|
+
And the contents of the page at that URL must match 'OK' exactly for the healthcheck to pass. If unsuccessful, the healthcheck is repeated every second, until a timeout of 60 seconds is reached, at which point the rolling deployment is aborted, and a progress summary displayed.
|
345
|
+
|
346
|
+
The result can also be specified as a regular expression, which gives more flexibility. For example:
|
347
|
+
|
348
|
+
```ruby
|
349
|
+
ec2_roles :name => "web",
|
350
|
+
:variables => {
|
351
|
+
:healthcheck => {
|
352
|
+
:path => '/status',
|
353
|
+
:port => 80,
|
354
|
+
:result => /^(OK|Success)$/
|
355
|
+
}
|
356
|
+
}
|
357
|
+
```
|
358
|
+
|
359
|
+
The result can also be specified as an array (of strings and/or regular expressions), in which case the result of the health check is successful if the response matches any of the items in the array. For example:
|
360
|
+
|
361
|
+
```ruby
|
362
|
+
ec2_roles :name => "web",
|
363
|
+
:variables => {
|
364
|
+
:healthcheck => {
|
365
|
+
:path => '/status',
|
366
|
+
:port => 80,
|
367
|
+
:result => ['OK', /^\s*Success/]
|
368
|
+
}
|
369
|
+
}
|
370
|
+
```
|
345
371
|
|
346
372
|
The default timeout of 60 seconds can be overridden by setting ':timeout' to a custom value in seconds. The protocol used defaults to 'http://', however you can switch to 'https://' by setting ':https' equal to 'true'. For example:
|
347
373
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capify-ec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: -4040006510
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
9
|
+
- 3
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 1.4.
|
11
|
+
- 5
|
12
|
+
version: 1.4.3.pre5
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Noah Cantor
|
@@ -20,7 +20,7 @@ autorequire:
|
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
22
|
|
23
|
-
date: 2013-
|
23
|
+
date: 2013-04-09 00:00:00 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: fog
|