10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/capistrano/bundle_rsync/bundler.rb', line 10
def rsync
hosts = release_roles(:all)
on hosts, in: :groups, limit: config.max_parallels(hosts) do
within release_path do
execute :mkdir, '-p', '.bundle'
end
end
lines = <<-EOS
---
BUNDLE_FROZEN: '1'
BUNDLE_PATH: #{shared_path.join('bundle')}
BUNDLE_WITHOUT: development:test
BUNDLE_DISABLE_SHARED_GEMS: '1'
BUNDLE_BIN: #{release_path.join('bin')}
EOS
bundle_config_path = "#{config.local_base_path}/bundle_config"
File.open(bundle_config_path, "w") {|file| file.print(lines) }
rsync_options = config.rsync_options
Parallel.each(hosts, in_threads: config.max_parallels(hosts)) do |host|
ssh = config.build_ssh_command(host)
if config_files = config.config_files
config_files.each do |config_file|
basename = File.basename(config_file)
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config_file} #{host}:#{release_path}/config/#{basename}"
end
end
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config.local_bundle_path}/ #{host}:#{shared_path}/bundle/"
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{bundle_config_path} #{host}:#{release_path}/.bundle/config"
end
unless fetch(:bundle_rsync_local_release_path)
releases = capture(:ls, '-x', config.local_releases_path).split
if releases.count >= config.keep_releases
directories = (releases - releases.last(config.keep_releases))
if directories.any?
directories_str = directories.map do |release|
releases_path.join(release)
end.join(" ")
execute :rm, '-rf', directories_str
end
end
end
end
|