s3_deployer 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 844de0917a0347758d662fe6dc799217dc7d16c5
4
- data.tar.gz: 3ea7e007d1c486ed7186fc76703de849a138b984
3
+ metadata.gz: 112d76344eda70ff7dd8654c4655f28a15350a24
4
+ data.tar.gz: 3d707335451e1f02cc0501ab5fcf31c1663ea063
5
5
  SHA512:
6
- metadata.gz: 3b7f997173a27444996997c954c2d75c3c6dc9ee8766841d9ffb146da5d7fb588d15bcabf9420118a1a6f9548327fb7d536db96832227019b9fe38591a870453
7
- data.tar.gz: 6d8cc55576a7c732503dfa014b6a69f3c3e3c880d6499a7208cc5578694c98afbbf6cc6007710915d0e15c5569ac1708ad38a67b4d37a51cc6f7aa265b92381a
6
+ metadata.gz: 0000396d0830c7b0bc4f12fecd6b0a73725c5f24323a1a3c2902fdb321046c9b6a54bd60c1c419cd7106372e4dec14d0f26b08b4a83d6d119474e615c0db867a
7
+ data.tar.gz: e66c981731ea5c16fc849bc774ebd18280a92a5cf9273b26eead74aab731d1a77ee2cee470da54fa0befaa5615598a5d67eb537c578c9f230352a6acf6a8bc17
data/README.md CHANGED
@@ -16,6 +16,20 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install s3_deployer
18
18
 
19
+ ## Features
20
+
21
+ * Versioned deploys
22
+ * Separated 'stage' (uploading code to S3) and 'switch' (switching to the right code version) tasks
23
+ (with ability to combine them with the 'deploy' task)
24
+ * Parallel uploads
25
+ * Retries in case of upload failures
26
+ * Optional compression (by regexps, see example below)
27
+ * before/after hooks for every step
28
+ * Separate environments support
29
+ * Automatic maintaining of the list of versions and mapping them to the list of git commits
30
+ * Rollback via 'switch' command
31
+ * Colorized output :)
32
+
19
33
  ## Usage
20
34
 
21
35
  You need to specify s3_deployer_config.rb file in your home directory, which may look like this:
@@ -8,6 +8,10 @@ class S3Deployer
8
8
  def yellow(text)
9
9
  self.new(33).wrap(text)
10
10
  end
11
+
12
+ def red(text)
13
+ self.new(31).wrap(text)
14
+ end
11
15
  end
12
16
 
13
17
  def initialize(color)
@@ -1,3 +1,3 @@
1
1
  class S3Deployer
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
data/lib/s3_deployer.rb CHANGED
@@ -13,6 +13,8 @@ require "s3_deployer/version"
13
13
  class S3Deployer
14
14
  DATE_FORMAT = "%Y%m%d%H%M%S"
15
15
  CURRENT_REVISION = "CURRENT_REVISION"
16
+ RETRY_TIMES = [1, 3, 8].freeze
17
+
16
18
  class << self
17
19
  attr_reader :config
18
20
 
@@ -166,7 +168,9 @@ class S3Deployer
166
168
 
167
169
  def get_value(key)
168
170
  puts "Retrieving value #{key} on S3"
169
- Aws::S3::Resource.new.bucket(config.bucket).object(key).get.body.read
171
+ retry_block(RETRY_TIMES.dup) do
172
+ Aws::S3::Resource.new.bucket(config.bucket).object(key).get.body.read
173
+ end
170
174
  end
171
175
 
172
176
  def store_current_revision(revision)
@@ -188,7 +192,6 @@ class S3Deployer
188
192
  end
189
193
 
190
194
  def store_value(key, value)
191
- puts "Storing value #{colorize(:yellow, key)} on S3#{", #{colorize(:green, 'gzipped')}" if should_compress?(key)}"
192
195
  options = {acl: "public-read"}
193
196
  if config.cache_control && !config.cache_control.empty?
194
197
  options[:cache_control] = config.cache_control
@@ -197,7 +200,28 @@ class S3Deployer
197
200
  options[:content_encoding] = "gzip"
198
201
  value = compress(value)
199
202
  end
200
- Aws::S3::Resource.new.bucket(config.bucket).object(key).put(options.merge(body: value))
203
+ retry_block(RETRY_TIMES.dup) do
204
+ puts "Storing value #{colorize(:yellow, key)} on S3#{", #{colorize(:green, 'gzipped')}" if should_compress?(key)}"
205
+ Aws::S3::Resource.new.bucket(config.bucket).object(key).put(options.merge(body: value))
206
+ end
207
+ end
208
+
209
+ def retry_block(sleep_times, &block)
210
+ block.call
211
+ rescue Exception => e
212
+ puts "#{colorize(:red, "Error!")} #{e}\n\n#{e.backtrace.take(3).join("\n")}"
213
+ no_retry_exceptions = [Aws::S3::Errors::NoSuchKey]
214
+ if no_retry_exceptions.any? { |exc| e.is_a?(exc) }
215
+ raise e
216
+ elsif !sleep_times.empty?
217
+ sleep_time = sleep_times.shift
218
+ puts "Still have #{colorize(:yellow, "#{sleep_times.count} retries")}, so waiting for #{colorize(:yellow, "#{sleep_time} seconds")} and retrying..."
219
+ sleep sleep_time
220
+ retry_block(sleep_times, &block)
221
+ else
222
+ puts "Out of retries, failing..."
223
+ raise e
224
+ end
201
225
  end
202
226
 
203
227
  def should_compress?(key)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Astashov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-30 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo