capistrano-lazy_cleanup 0.2.0 → 0.3.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: bf005c37322af39afaf4bcee9a0bd1688f5a91aa
4
- data.tar.gz: a2e9d14168f5f86b767bb3f159a4f694dd85c56d
3
+ metadata.gz: 878aba5677332a555449014b36377fa1f5d3b05b
4
+ data.tar.gz: b29aafae15aee742faf39f162db3e92cb0c2e18c
5
5
  SHA512:
6
- metadata.gz: 51bf43bbc1ac8f075be26263cd14018705d76bc78d11c945f97aab4462d4d902c9591688845a1fd3e18455550691099477765cecc559e9ee71488a147e185e17
7
- data.tar.gz: efff4364a823d48d899328d5afe4d595d3918694511c1394b88fa38dc2f7fabff213abd0c65260624b38183044906bd4dde019255dc818952cec60c37d946490
6
+ metadata.gz: f76d038cc88b5b60102368ad39bbf20e5eec18dcb234ddd01eb41cff88db4b1c29b65ec300459d5fabff8952743ec1d0eca5e24ab9fb9b8a3e428d821a8d0159
7
+ data.tar.gz: a90dcf4bf5958ec2ae1abd4987f457ea1a1c5cb6a9cce32b167f489b15601c09a283af09f246efa29096b6712288c93851d8fddd3a53f0ecb074d3df95cf5eb6
data/README.md CHANGED
@@ -21,13 +21,38 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
+ Capfile
25
+
24
26
  ```ruby
25
- require 'capistrano/deploy' # This should be required in advance
27
+ # Load DSL and set up stages
28
+ require "capistrano/setup"
29
+
30
+ # Include default deployment tasks
31
+ require "capistrano/deploy" # This should be required in advance
26
32
 
27
33
  # Capfile
28
34
  require 'capistrano/lazy_cleanup'
29
35
  ```
30
36
 
37
+ ## Configuration
38
+
39
+ Capistrano::LazyCleanup can be used out of the box, but you can further customize the configuration at your `deploy.rb`.
40
+
41
+ ```ruby
42
+ # Defaults to "#{fetch(:tmp_dir)}/cap-lazy-cleanup-#{fetch(:application)}.XXXXXXXXXX"
43
+ set :lazy_cleanup_old_releases_path_template, "/tmp/my-old-releases.XXXXXXXXXX"
44
+ ```
45
+
46
+ ## What exactly does the `offloading` mean?
47
+
48
+ On heavy application, it takes time to execute `deploy:cleanup` and `deploy:cleanup_rollback`. This is mainly due to heavy I/O caused by `rm -rf`. The kernel visits and unlink all the directories and files in old release paths. This costs heavy I/O as well as CPU cost.
49
+
50
+ This gem replaces `rm -rf` with `mktemp` and `mv`. The old release paths are moved to temporary directory. Capistrano and the kernel should handle only the top directory on deployment. After the deployment, files in temporary directory will be eventually cleaned up by low-priorty processes provided by OS.
51
+
52
+ ## Caveats
53
+
54
+ This gem heavily uses `fetch(:tmp_dir)` as the temporary directory. Therefore, when the combination of deployment size and frequency overwhelms cleanup cycle of your OS, you might encounter disk full issue. You can mitigate this by specifying additional fast cleanup rule on `lazy_cleanup_old_releases_path_template`. (e.g. `tmpwatch -umc 1 /tmp/cap-lazy-cleanup*`)
55
+
31
56
  ## Development
32
57
 
33
58
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,4 +1,5 @@
1
1
  require "capistrano/lazy_cleanup/version"
2
+ require "capistrano/lazy_cleanup/defaults"
2
3
 
3
4
  module Capistrano
4
5
  module LazyCleanup
@@ -0,0 +1,14 @@
1
+ require 'rake'
2
+
3
+ module Capistrano
4
+ module LazyCleanup
5
+ module Defaults
6
+ end
7
+ end
8
+ end
9
+
10
+ # TODO: If Capistrano::Plugin system becomes stable, refactor these code.
11
+
12
+ Rake::Task.define_task('load:defaults') do
13
+ set_if_empty :lazy_cleanup_old_releases_path_template, -> { "#{fetch(:tmp_dir)}/cap-lazy-cleanup-#{fetch(:application)}.XXXXXXXXXX" }
14
+ end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module LazyCleanup
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -24,7 +24,7 @@ namespace :capistrano do
24
24
  debug t(:no_current_release, host: host.to_s)
25
25
  end
26
26
  if directories.any?
27
- temp_dir = capture(:mktemp, '-d')
27
+ temp_dir = capture(:mktemp, '-d', fetch(:lazy_cleanup_old_releases_path_template))
28
28
  execute :mv, *directories, temp_dir
29
29
  else
30
30
  info t(:no_old_releases, host: host.to_s, keep_releases: fetch(:keep_releases))
@@ -42,7 +42,7 @@ namespace :capistrano do
42
42
  execute :tar, "-czf",
43
43
  deploy_path.join("rolled-back-release-#{last_release}.tar.gz"),
44
44
  last_release_path
45
- temp_dir = capture(:mktemp, '-d')
45
+ temp_dir = capture(:mktemp, '-d', fetch(:lazy_cleanup_old_releases_path_template))
46
46
  execute :mv, last_release_path, temp_dir
47
47
  else
48
48
  debug "Last release is the current release, skip cleanup_rollback."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-lazy_cleanup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takumasa Ochi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-15 00:00:00.000000000 Z
11
+ date: 2019-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -100,6 +100,7 @@ files:
100
100
  - bin/setup
101
101
  - capistrano-lazy_cleanup.gemspec
102
102
  - lib/capistrano/lazy_cleanup.rb
103
+ - lib/capistrano/lazy_cleanup/defaults.rb
103
104
  - lib/capistrano/lazy_cleanup/version.rb
104
105
  - lib/capistrano/tasks/lazy_cleanup.rake
105
106
  homepage: https://github.com/aeroastro/capistrano-lazy_cleanup