capsum 1.0.4 → 1.0.5
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 +4 -4
- data/capsum.gemspec +2 -2
- data/lib/capistrano/rsync.rb +1 -123
- data/lib/capistrano/tasks/rsync.rake +93 -0
- data/lib/capsum/daemons.rb +20 -22
- data/lib/capsum/foundation.rb +0 -1
- data/lib/capsum/sidekiq.rb +1 -1
- data/lib/capsum/version.rb +2 -2
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d12f8b33e375d6f689d08c042abb011332b2e72c
|
4
|
+
data.tar.gz: 86fd10b0b7c8df2146f2541447268cf0e59feb78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db6124af1d0de49e1e22bf153d988cf65cb92b05c50b8fc70ebe4ed061cf3f4c3403fa77cbd25555ba27685502579f47edc9b57c71d741873917bfc2bcd09a01
|
7
|
+
data.tar.gz: e1630ea25d11ebbce9110e488b659b822e4d62b36a30c9cf0480fab14057e426b71ba7c1fbc48568feaff003ab81da7afbdb44e59bf8f67ca43f9970c5ad7095
|
data/capsum.gemspec
CHANGED
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
# Dependency Gems
|
22
|
-
spec.add_dependency "capistrano", "~> 3.
|
22
|
+
spec.add_dependency "capistrano", "~> 3.6.0"
|
23
23
|
# spec.add_dependency "capistrano-rsync", "~> 1.0.2" # broken, wait update
|
24
|
-
spec.add_dependency "capistrano-rails", "~> 1.1.
|
24
|
+
spec.add_dependency "capistrano-rails", "~> 1.1.7"
|
25
25
|
spec.add_development_dependency "capistrano-sidekiq", Capsum::CAPISTRANO_SIDEKIQ_REQUIREMENT # optional
|
26
26
|
|
27
27
|
# spec.add_dependency "capistrano-helpers", "~> 0.7.1"
|
data/lib/capistrano/rsync.rb
CHANGED
@@ -1,123 +1 @@
|
|
1
|
-
|
2
|
-
# might change between minor or patch version releases. They make up the
|
3
|
-
# private API and internals of Capistrano::Rsync. If you think something should
|
4
|
-
# be public for extending and hooking, please let me know!
|
5
|
-
|
6
|
-
rsync_cache = lambda do
|
7
|
-
cache = fetch(:rsync_cache)
|
8
|
-
cache = deploy_to + "/" + cache if cache && cache !~ /^\//
|
9
|
-
cache
|
10
|
-
end
|
11
|
-
|
12
|
-
# PATCH https://github.com/moll/capistrano-rsync/pull/13
|
13
|
-
# Use cap3's load:defaults to set default vars so that they can be overridden.
|
14
|
-
namespace :load do
|
15
|
-
task :defaults do
|
16
|
-
set :rsync_options, %w[--recursive --delete --delete-excluded --exclude .git*]
|
17
|
-
set :rsync_copy, "rsync --archive --acls --xattrs"
|
18
|
-
|
19
|
-
# Stage is used on your local machine for rsyncing from.
|
20
|
-
set :rsync_stage, "tmp/deploy"
|
21
|
-
|
22
|
-
# Cache is used on the server to copy files to from to the release
|
23
|
-
# directory. Saves you rsyncing your whole app folder each time. If you nil
|
24
|
-
# rsync_cache, Capistrano::Rsync will sync straight to the release path.
|
25
|
-
set :rsync_cache, "shared/deploy"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
Rake::Task["deploy:check"].enhance ["rsync:hook_scm"]
|
31
|
-
Rake::Task["deploy:updating"].enhance ["rsync:hook_scm"]
|
32
|
-
|
33
|
-
desc "Stage and rsync to the server (or its cache)."
|
34
|
-
task :rsync => %w[rsync:stage] do
|
35
|
-
roles(:all).each do |role|
|
36
|
-
user = role.user + "@" if !role.user.nil?
|
37
|
-
|
38
|
-
rsync = %w[rsync]
|
39
|
-
rsync.concat fetch(:rsync_options)
|
40
|
-
|
41
|
-
if (port = role.port)
|
42
|
-
rsync += [ "-e", "ssh -p #{port}" ]
|
43
|
-
end
|
44
|
-
|
45
|
-
rsync << fetch(:rsync_stage) + "/"
|
46
|
-
rsync << "#{user}#{role.hostname}:#{rsync_cache.call || release_path}"
|
47
|
-
|
48
|
-
Kernel.system *rsync
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
namespace :rsync do
|
53
|
-
task :hook_scm do
|
54
|
-
Rake::Task.define_task("#{scm}:check") do
|
55
|
-
invoke "rsync:check"
|
56
|
-
end
|
57
|
-
|
58
|
-
Rake::Task.define_task("#{scm}:create_release") do
|
59
|
-
invoke "rsync:release"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
task :check do
|
64
|
-
# Everything's a-okay inherently!
|
65
|
-
end
|
66
|
-
|
67
|
-
task :create_stage do
|
68
|
-
repo_url = fetch(:repo_url, ".")
|
69
|
-
deploy_cache_dir = fetch(:rsync_stage)
|
70
|
-
if File.directory?(deploy_cache_dir)
|
71
|
-
repo_url_changed = false
|
72
|
-
Dir.chdir deploy_cache_dir do
|
73
|
-
absolute_repo_url = File.absolute_path(repo_url)
|
74
|
-
absolute_cache_repo_url = File.absolute_path(`git config --get remote.origin.url`.chomp)
|
75
|
-
repo_url_changed = (absolute_repo_url != absolute_cache_repo_url)
|
76
|
-
end
|
77
|
-
|
78
|
-
if repo_url_changed
|
79
|
-
run_locally { execute :rm, "-rf", deploy_cache_dir }
|
80
|
-
else
|
81
|
-
next
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
clone = %W[git clone]
|
86
|
-
clone << repo_url
|
87
|
-
clone << deploy_cache_dir
|
88
|
-
run_locally { execute *clone }
|
89
|
-
end
|
90
|
-
|
91
|
-
task :set_current_revision do
|
92
|
-
Dir.chdir fetch(:rsync_stage) do
|
93
|
-
set :current_revision, "#{`git rev-parse --short HEAD`}".chomp
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
desc "Stage the repository in a local directory."
|
98
|
-
task :stage => %w[create_stage] do
|
99
|
-
Dir.chdir fetch(:rsync_stage) do
|
100
|
-
update = %W[git fetch --quiet --all --prune]
|
101
|
-
run_locally { execute *update }
|
102
|
-
|
103
|
-
checkout = %W[git reset --hard origin/#{fetch(:branch)}]
|
104
|
-
run_locally { execute *checkout }
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
desc "Copy the code to the releases directory."
|
109
|
-
task :release => %w[rsync] do
|
110
|
-
# Skip copying if we've already synced straight to the release directory.
|
111
|
-
next if !fetch(:rsync_cache)
|
112
|
-
|
113
|
-
copy = %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" "#{release_path}/")
|
114
|
-
on roles(:all) do
|
115
|
-
execute copy
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
# Matches the naming scheme of git tasks.
|
120
|
-
# Plus was part of the public API in Capistrano::Rsync <= v0.2.1.
|
121
|
-
task :create_release => %w[release]
|
122
|
-
end
|
123
|
-
|
1
|
+
load File.expand_path("../tasks/rsync.rake", __FILE__)
|
@@ -0,0 +1,93 @@
|
|
1
|
+
set_if_empty :rsync_options, %w(--recursive --delete --delete-excluded --exclude .git*)
|
2
|
+
set_if_empty :rsync_copy, "rsync --archive --acls --xattrs"
|
3
|
+
|
4
|
+
# Stage is used on your local machine for rsyncing from.
|
5
|
+
set_if_empty :rsync_stage, "tmp/deploy"
|
6
|
+
|
7
|
+
# Cache is used on the server to copy files to from to the release directory.
|
8
|
+
set_if_empty :rsync_cache, "shared/deploy"
|
9
|
+
|
10
|
+
rsync_cache = lambda do
|
11
|
+
cache = fetch(:rsync_cache)
|
12
|
+
cache = deploy_to + "/" + cache if cache && cache !~ /^\//
|
13
|
+
cache
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :rsync do
|
17
|
+
task :check do
|
18
|
+
# Everything's a-okay inherently!
|
19
|
+
end
|
20
|
+
|
21
|
+
task :set_current_revision do
|
22
|
+
Dir.chdir fetch(:rsync_stage) do
|
23
|
+
set :current_revision, "#{`git rev-parse --short HEAD`}".chomp
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
task :create_stage do
|
28
|
+
repo_url = fetch(:repo_url, ".")
|
29
|
+
deploy_cache_dir = fetch(:rsync_stage)
|
30
|
+
if File.directory?(deploy_cache_dir)
|
31
|
+
repo_url_changed = false
|
32
|
+
Dir.chdir deploy_cache_dir do
|
33
|
+
absolute_repo_url = File.absolute_path(repo_url)
|
34
|
+
absolute_cache_repo_url = File.absolute_path(`git config --get remote.origin.url`.chomp)
|
35
|
+
repo_url_changed = (absolute_repo_url != absolute_cache_repo_url)
|
36
|
+
end
|
37
|
+
|
38
|
+
if repo_url_changed
|
39
|
+
run_locally { execute :rm, "-rf", deploy_cache_dir }
|
40
|
+
else
|
41
|
+
next
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
clone = %w(git clone)
|
46
|
+
clone << repo_url
|
47
|
+
clone << deploy_cache_dir
|
48
|
+
run_locally { execute *clone }
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Stage the repository in a local directory."
|
52
|
+
task stage: %w(create_stage) do
|
53
|
+
Dir.chdir fetch(:rsync_stage) do
|
54
|
+
update = %w(git fetch --quiet --all --prune)
|
55
|
+
run_locally { execute *update }
|
56
|
+
|
57
|
+
checkout = %W(git reset --hard origin/#{fetch(:branch)})
|
58
|
+
run_locally { execute *checkout }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
desc "Stage and rsync to the server (or its cache)."
|
63
|
+
task :sync => %w(stage) do
|
64
|
+
|
65
|
+
roles(:all).each do |role|
|
66
|
+
user = role.user + "@" if role.user
|
67
|
+
|
68
|
+
rsync = %w(rsync)
|
69
|
+
rsync.concat fetch(:rsync_options)
|
70
|
+
|
71
|
+
if (port = role.port)
|
72
|
+
rsync += [ "-e", %("ssh -p #{port}") ]
|
73
|
+
end
|
74
|
+
|
75
|
+
rsync << fetch(:rsync_stage) + "/"
|
76
|
+
rsync << "#{user}#{role.hostname}:#{rsync_cache.call || release_path}"
|
77
|
+
|
78
|
+
# Kernel.system *rsync
|
79
|
+
run_locally { execute *rsync }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "Copy the code to the releases directory."
|
84
|
+
task :create_release => %w(sync) do
|
85
|
+
# Skip copying if we've already synced straight to the release directory.
|
86
|
+
next if !fetch(:rsync_cache)
|
87
|
+
|
88
|
+
copy = %(#{fetch(:rsync_copy)} "#{rsync_cache.call}/" "#{release_path}/")
|
89
|
+
on roles(:all) do
|
90
|
+
execute copy
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/lib/capsum/daemons.rb
CHANGED
@@ -17,7 +17,7 @@ namespace :daemons do
|
|
17
17
|
fetch(:daemon_list).each do |daemon|
|
18
18
|
script_path = release_path.join("daemons", daemon[:name])
|
19
19
|
content = convert_daemon_script(daemon)
|
20
|
-
|
20
|
+
|
21
21
|
on roles (daemon[:role] || :all) do |host|
|
22
22
|
execute :mkdir, "-pv", script_path.dirname
|
23
23
|
upload! StringIO.new(content), script_path
|
@@ -56,15 +56,14 @@ namespace :daemons do
|
|
56
56
|
indent = (str.scan(/^[ \t]*(?=\S)/).min || "").size
|
57
57
|
str.gsub(/^[ \t]{#{indent}}/, '')
|
58
58
|
end
|
59
|
-
|
60
|
-
after 'deploy:updated', :upload_daemons
|
61
59
|
end
|
60
|
+
after 'deploy:updated', 'daemons:upload_daemons'
|
62
61
|
|
63
62
|
|
64
63
|
# Capistrano::Configuration.instance(true).load do
|
65
|
-
|
64
|
+
|
66
65
|
# namespace :daemons do
|
67
|
-
# desc "Start daemons process"
|
66
|
+
# desc "Start daemons process"
|
68
67
|
# task :start, :roles => :app do
|
69
68
|
# find_servers(:roles => :app).each do |server|
|
70
69
|
# matcher = server.options[:daemons]
|
@@ -73,21 +72,21 @@ end
|
|
73
72
|
# end
|
74
73
|
# end
|
75
74
|
# end
|
76
|
-
|
77
|
-
# desc "Stop daemons process"
|
75
|
+
|
76
|
+
# desc "Stop daemons process"
|
78
77
|
# task :stop, :roles => :app do
|
79
78
|
# daemon_list.each do |daemon|
|
80
|
-
# run "cd #{current_path}; #{daemon[:stop]}"
|
79
|
+
# run "cd #{current_path}; #{daemon[:stop]}"
|
81
80
|
# end
|
82
81
|
# end
|
83
82
|
|
84
|
-
# desc "Restart daemons process"
|
83
|
+
# desc "Restart daemons process"
|
85
84
|
# task :restart, :roles => :app do
|
86
85
|
# daemons.stop
|
87
86
|
# sleep(3)
|
88
87
|
# daemons.start
|
89
88
|
# end
|
90
|
-
|
89
|
+
|
91
90
|
# desc "setup daemons to autostart"
|
92
91
|
# task :setup_autostart, :roles => :app do
|
93
92
|
# autostart_server_commands = fetch(:autostart_server_commands)
|
@@ -95,23 +94,23 @@ end
|
|
95
94
|
# find_servers(:roles => :app).each do |server|
|
96
95
|
# matcher = server.options[:daemons]
|
97
96
|
# autostart_server_commands[server] ||= []
|
98
|
-
|
97
|
+
|
99
98
|
# daemon_list.each do |daemon|
|
100
99
|
# autostart_server_commands[server] << "cd #{current_path}; #{daemon[:start]}" if match(matcher, daemon)
|
101
100
|
# end
|
102
101
|
# end
|
103
102
|
# end
|
104
|
-
|
103
|
+
|
105
104
|
# def match(matcher, daemon)
|
106
105
|
# return matcher.call(daemon[:name]) if matcher.respond_to?(:call)
|
107
106
|
# return matcher.match(daemon[:name]) if matcher.respond_to?(:match)
|
108
|
-
|
107
|
+
|
109
108
|
# !!matcher # to boolean
|
110
109
|
# end
|
111
|
-
|
110
|
+
|
112
111
|
# def daemon_list
|
113
112
|
# settings = fetch(:daemons, [])
|
114
|
-
|
113
|
+
|
115
114
|
# case settings
|
116
115
|
# when Array
|
117
116
|
# settings.map { |setting| parse_daemon(setting) }
|
@@ -121,10 +120,10 @@ end
|
|
121
120
|
# [ parse_daemon(settings) ]
|
122
121
|
# end
|
123
122
|
# end
|
124
|
-
|
123
|
+
|
125
124
|
# def parse_daemon(source, options = {})
|
126
125
|
# daemon = {}
|
127
|
-
|
126
|
+
|
128
127
|
# case source
|
129
128
|
# when Array
|
130
129
|
# daemon[:start] = source.first
|
@@ -136,16 +135,15 @@ end
|
|
136
135
|
# daemon[:start] = command.gsub("%{command}", "start")
|
137
136
|
# daemon[:stop] = command.gsub("%{command}", "stop")
|
138
137
|
# end
|
139
|
-
|
138
|
+
|
140
139
|
# daemon[:name] = daemon[:start] if daemon[:name].nil?
|
141
140
|
# daemon
|
142
141
|
# end
|
143
142
|
# end
|
144
143
|
|
145
|
-
# before "autostart:update_crontab", "daemons:setup_autostart"
|
144
|
+
# before "autostart:update_crontab", "daemons:setup_autostart"
|
146
145
|
|
147
|
-
# after "deploy:start", "daemons:start"
|
148
|
-
# after "deploy:stop", "daemons:stop"
|
146
|
+
# after "deploy:start", "daemons:start"
|
147
|
+
# after "deploy:stop", "daemons:stop"
|
149
148
|
# after "deploy:restart", "daemons:restart"
|
150
149
|
# end
|
151
|
-
|
data/lib/capsum/foundation.rb
CHANGED
data/lib/capsum/sidekiq.rb
CHANGED
data/lib/capsum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capsum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sunteya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: 3.6.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
26
|
+
version: 3.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: capistrano-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.1.
|
33
|
+
version: 1.1.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.1.
|
40
|
+
version: 1.1.7
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: capistrano-sidekiq
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.5.
|
47
|
+
version: 0.5.4
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.5.
|
54
|
+
version: 0.5.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- Rakefile
|
96
96
|
- capsum.gemspec
|
97
97
|
- lib/capistrano/rsync.rb
|
98
|
+
- lib/capistrano/tasks/rsync.rake
|
98
99
|
- lib/capsum.rb
|
99
100
|
- lib/capsum/autostart.rb
|
100
101
|
- lib/capsum/bundler.rb
|
@@ -129,8 +130,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
130
|
version: '0'
|
130
131
|
requirements: []
|
131
132
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.5.1
|
133
134
|
signing_key:
|
134
135
|
specification_version: 4
|
135
136
|
summary: Collect gems and recipes related capistrano.
|
136
137
|
test_files: []
|
138
|
+
has_rdoc:
|