capistrano_multiconfig_parallel 2.0.0.rc3 → 2.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/capistrano_multiconfig_parallel.gemspec +1 -0
- data/lib/capistrano_multiconfig_parallel/all.rb +1 -0
- data/lib/capistrano_multiconfig_parallel/application.rb +26 -11
- data/lib/capistrano_multiconfig_parallel/celluloid/bundler_worker.rb +42 -9
- data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_manager.rb +1 -1
- data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb +3 -6
- data/lib/capistrano_multiconfig_parallel/celluloid/process_runner.rb +5 -6
- data/lib/capistrano_multiconfig_parallel/classes/bundler_status.rb +28 -0
- data/lib/capistrano_multiconfig_parallel/classes/child_process_status.rb +1 -1
- data/lib/capistrano_multiconfig_parallel/classes/job.rb +8 -2
- data/lib/capistrano_multiconfig_parallel/classes/job_command.rb +31 -27
- data/lib/capistrano_multiconfig_parallel/classes/runner_status.rb +22 -12
- data/lib/capistrano_multiconfig_parallel/helpers/core_helper.rb +3 -3
- data/lib/capistrano_multiconfig_parallel/helpers/internal_helper.rb +9 -0
- data/lib/capistrano_multiconfig_parallel/version.rb +1 -1
- metadata +22 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac23d7c22bd2218a3698e42af759ca31f5acc788
|
4
|
+
data.tar.gz: 36698d180f0f36eb03c7d31d6a7de9151083c577
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40ca91f76026730c6a2202980b01a697ce81da78f2929405d2add331abc2c43b74a68db273d4698def4eaf9356814b0fa481f263fa340a8924c7e33ba89ed99c
|
7
|
+
data.tar.gz: 9874920c58f868739a8aa9a07a2d03c0d873a6850d3ce4838b87b6f14b27b6dd171dc0f3228dab9289664616cac78ced4a38e8a46709ac53b6da4765e67f15d2
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.add_runtime_dependency 'inquirer', '~> 0.2', '>= 0.2'
|
31
31
|
s.add_runtime_dependency 'devnull','~> 0.1', '>= 0.1'
|
32
32
|
s.add_runtime_dependency 'capistrano_sentinel', '>= 0.0', '>= 0.0.16'
|
33
|
+
s.add_runtime_dependency 'ruby-progressbar', '~> 1.8', '>= 1.8.1'
|
33
34
|
|
34
35
|
s.add_development_dependency 'rake', '>= 10.4', '>= 10.4'
|
35
36
|
s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4'
|
@@ -4,7 +4,8 @@ module CapistranoMulticonfigParallel
|
|
4
4
|
class Application
|
5
5
|
include CapistranoMulticonfigParallel::ApplicationHelper
|
6
6
|
|
7
|
-
attr_reader :stage_apps, :top_level_tasks, :jobs, :condition, :manager, :dependency_tracker, :application, :stage, :name, :args, :argv, :default_stage
|
7
|
+
attr_reader :stage_apps, :top_level_tasks, :jobs, :condition, :manager, :dependency_tracker, :application, :stage, :name, :args, :argv, :default_stage,:patched_job_paths
|
8
|
+
attr_writer :patched_job_paths
|
8
9
|
|
9
10
|
def initialize
|
10
11
|
Celluloid.boot unless Celluloid.running?
|
@@ -12,6 +13,8 @@ module CapistranoMulticonfigParallel
|
|
12
13
|
@stage_apps = multi_apps? ? app_names_from_stages : []
|
13
14
|
collect_command_line_tasks(CapistranoMulticonfigParallel.original_args)
|
14
15
|
@jobs = []
|
16
|
+
@checked_job_paths = []
|
17
|
+
@patched_job_paths = [] # for deploy
|
15
18
|
end
|
16
19
|
|
17
20
|
def start
|
@@ -50,13 +53,13 @@ module CapistranoMulticonfigParallel
|
|
50
53
|
end
|
51
54
|
|
52
55
|
def verify_valid_data
|
53
|
-
|
54
|
-
|
56
|
+
return if @top_level_tasks != ['default']
|
57
|
+
raise_invalid_job_config
|
55
58
|
end
|
56
59
|
|
57
60
|
def raise_invalid_job_config
|
58
|
-
|
59
|
-
|
61
|
+
puts 'Invalid execution, please call something such as `multi_cap production deploy`, where production is a stage you have defined'.red
|
62
|
+
exit(false)
|
60
63
|
end
|
61
64
|
|
62
65
|
def initialize_data
|
@@ -105,7 +108,6 @@ module CapistranoMulticonfigParallel
|
|
105
108
|
|
106
109
|
def process_jobs
|
107
110
|
return unless @jobs.present?
|
108
|
-
FileUtils.rm Dir["#{log_directory}/worker_*.log"]
|
109
111
|
if configuration.multi_secvential.to_s.downcase == 'true'
|
110
112
|
@jobs.each(&:execute_standard_deploy)
|
111
113
|
else
|
@@ -153,6 +155,8 @@ module CapistranoMulticonfigParallel
|
|
153
155
|
end
|
154
156
|
|
155
157
|
def run
|
158
|
+
FileUtils.rm Dir["#{log_directory}/worker_*.log"]
|
159
|
+
FileUtils.rm Dir["#{log_directory}/multi_cap_worker_*.log"]
|
156
160
|
options = {}
|
157
161
|
if custom_command?
|
158
162
|
options = verify_options_custom_command(options)
|
@@ -214,17 +218,27 @@ module CapistranoMulticonfigParallel
|
|
214
218
|
|
215
219
|
env_options = options['env_options']
|
216
220
|
job_env_options = custom_command? ? env_options.except(action_key) : env_options
|
221
|
+
|
217
222
|
job = CapistranoMulticonfigParallel::Job.new(self, options.merge(
|
218
|
-
|
219
|
-
|
220
|
-
|
223
|
+
action: custom_command? && env_options[action_key].present? ? env_options[action_key] : options['action'],
|
224
|
+
env_options: job_env_options,
|
225
|
+
path: job_path(options)
|
221
226
|
|
222
227
|
))
|
228
|
+
if job.job_gemfile.present?
|
229
|
+
if !@checked_job_paths.include?(job.job_path)
|
230
|
+
@checked_job_paths << job.job_path
|
231
|
+
bundler_worker = CapistranoMulticonfigParallel::BundlerWorker.new
|
232
|
+
bundler_worker.work(job) # make sure we have installed the dependencies first for this application
|
233
|
+
end
|
234
|
+
else
|
235
|
+
raise "Please make sure you have a Gemfile in the project root directory #{job.job_path}"
|
236
|
+
end
|
223
237
|
if job.find_capfile.blank?
|
224
238
|
raise "Please make sure you have a Capfile in the project root directory #{job.job_path}"
|
225
239
|
end
|
226
240
|
unless job.capistrano_sentinel_needs_updating?
|
227
|
-
|
241
|
+
raise "Please consider upgrading the gem #{job.capistrano_sentinel_name} to version #{job.loaded_capistrano_sentinel_version} from #{job.job_capistrano_sentinel_version} in #{job.job_path} "
|
228
242
|
end
|
229
243
|
@jobs << job unless job_can_tag_staging?(job)
|
230
244
|
end
|
@@ -234,7 +248,8 @@ module CapistranoMulticonfigParallel
|
|
234
248
|
end
|
235
249
|
|
236
250
|
def job_path(options)
|
237
|
-
options
|
251
|
+
path = options["path"].present? ? options["path"] : nil
|
252
|
+
path.present? && File.directory?(path) ? path : detect_root
|
238
253
|
end
|
239
254
|
|
240
255
|
def job_stage_valid?(options)
|
@@ -1,34 +1,67 @@
|
|
1
1
|
require_relative './celluloid_worker'
|
2
2
|
require_relative './process_runner'
|
3
|
-
require_relative '../classes/
|
3
|
+
require_relative '../classes/bundler_status'
|
4
4
|
module CapistranoMulticonfigParallel
|
5
5
|
class BundlerWorker
|
6
6
|
include CapistranoMulticonfigParallel::BaseActorHelper
|
7
7
|
|
8
|
-
|
8
|
+
attr_reader *[
|
9
|
+
:job,
|
10
|
+
:job_id,
|
11
|
+
:runner_status,
|
12
|
+
:log_prefix,
|
13
|
+
:checked_bundler_deps,
|
14
|
+
:total_dependencies,
|
15
|
+
:show_bundler
|
16
|
+
]
|
17
|
+
|
18
|
+
def work(job)
|
9
19
|
@job = job
|
10
|
-
@options = options.symbolize_keys
|
11
20
|
@job_id = job.id
|
12
21
|
@runner_status = nil
|
22
|
+
@log_prefix = 'bundler'
|
23
|
+
@checked_bundler_deps = []
|
24
|
+
@total_dependencies = bundler_dependencies.size
|
25
|
+
@show_bundler = true
|
26
|
+
progress_bar
|
13
27
|
check_missing_deps
|
14
28
|
end
|
15
29
|
|
16
|
-
def
|
17
|
-
"
|
30
|
+
def progress_bar
|
31
|
+
@progress_bar ||= ProgressBar.create(:title => "Checking app #{File.basename(@job.job_path)} bundler dependencies ", :starting_at => 0, :total => @total_dependencies.to_i, length: 160, :format => '%a |%b>>%i| %p%% %t | Processed: %c from %C gem dependencies')
|
32
|
+
end
|
33
|
+
|
34
|
+
def bundler_dependencies
|
35
|
+
builder = Bundler::Dsl.new
|
36
|
+
builder.eval_gemfile(@job.job_gemfile)
|
37
|
+
definition = builder.to_definition(@job.job_gemfile_lock, {})
|
38
|
+
@bundler_dependencies ||= definition.dependencies
|
39
|
+
end
|
40
|
+
|
41
|
+
def show_bundler_progress(data)
|
42
|
+
@show_bundler = false if data.to_s.include?("The Gemfile's dependencies are satisfied") || data.to_s.include?("Bundle complete")
|
43
|
+
gem_spec = bundler_dependencies.find{|spec| data.include?(spec.name) }
|
44
|
+
if @show_bundler == true && gem_spec.present?
|
45
|
+
@checked_bundler_deps = [gem_spec.name]
|
46
|
+
progress_bar.increment
|
47
|
+
elsif @show_bundler == false
|
48
|
+
progress_bar.finish
|
49
|
+
end
|
18
50
|
end
|
19
51
|
|
20
52
|
def check_missing_deps
|
21
53
|
command = @job.fetch_bundler_worker_command
|
22
|
-
log_to_file("bundler worker #{@job_id} executes: #{command}")
|
54
|
+
log_to_file("bundler worker #{@job_id} executes: #{command}", job_id: @job_id, prefix: @log_prefix)
|
23
55
|
do_bundle_sync_command(command)
|
24
56
|
end
|
25
57
|
|
26
58
|
def do_bundle_sync_command(command)
|
27
|
-
CapistranoMulticonfigParallel::ProcessRunner.
|
28
|
-
|
59
|
+
process_runner = CapistranoMulticonfigParallel::ProcessRunner.new
|
60
|
+
process_runner.work(@job, command, process_sync: :sync, actor: Actor.current, log_prefix: @log_prefix, runner_status_klass: CapistranoMulticonfigParallel::BundlerStatus, :callback => lambda {|runner_status| @runner_status = runner_status })
|
29
61
|
sleep(0.1) until @runner_status.present?
|
30
|
-
@runner_status.output_text
|
62
|
+
@runner_status.output_text
|
31
63
|
end
|
32
64
|
|
65
|
+
|
33
66
|
end
|
34
67
|
end
|
@@ -236,7 +236,7 @@ module CapistranoMulticonfigParallel
|
|
236
236
|
mailbox = worker.mailbox
|
237
237
|
log_to_file("worker_died: worker job #{job.inspect} with mailbox #{mailbox.inspect} and #{mailbox.address.inspect} died for reason: #{reason}")
|
238
238
|
return true if job.blank? || job.rolling_back? || job.action != 'deploy'
|
239
|
-
job.rollback_changes_to_application
|
239
|
+
#job.rollback_changes_to_application
|
240
240
|
@worker_to_job.delete(mailbox.address)
|
241
241
|
log_to_file("RESTARTING: worker job #{job.inspect} with mailbox #{mailbox.inspect} and #{mailbox.address.inspect} died for reason: #{reason}")
|
242
242
|
|
@@ -100,7 +100,7 @@ module CapistranoMulticonfigParallel
|
|
100
100
|
check_child_proces
|
101
101
|
command = job.fetch_deploy_command
|
102
102
|
log_to_file("worker #{@job_id} executes: #{command}")
|
103
|
-
@child_process.async.work(@job, command, actor: Actor.current, silent: true,
|
103
|
+
@child_process.async.work(@job, command, actor: Actor.current, silent: true, process_sync: :async, runner_status_klass: CapistranoMulticonfigParallel::ChildProcessStatus)
|
104
104
|
end
|
105
105
|
|
106
106
|
def check_child_proces
|
@@ -186,12 +186,9 @@ module CapistranoMulticonfigParallel
|
|
186
186
|
@manager.workers_terminated.signal('completed') if !@job.marked_for_dispatching_new_job? && @manager.present? && @manager.alive? && @manager.all_workers_finished?
|
187
187
|
end
|
188
188
|
|
189
|
-
def mark_for_dispatching_new_job
|
190
|
-
@job.will_dispatch_new_job = @job.new_jobs_dispatched.size + 1 unless @job.rolling_back?
|
191
|
-
end
|
192
189
|
|
193
|
-
def notify_finished(exit_status)
|
194
|
-
mark_for_dispatching_new_job if exit_status != 0
|
190
|
+
def notify_finished(exit_status, _runner_status)
|
191
|
+
@job.mark_for_dispatching_new_job if exit_status != 0
|
195
192
|
@job.exit_status = exit_status
|
196
193
|
finish_worker(exit_status)
|
197
194
|
return if exit_status == 0
|
@@ -27,14 +27,14 @@ module CapistranoMulticonfigParallel
|
|
27
27
|
|
28
28
|
@runner_status_klass = @options[:runner_status_klass].present? ? @options[:runner_status_klass] : RunnerStatus
|
29
29
|
@runner_status = @runner_status_klass.new(Actor.current, job, cmd, @options)
|
30
|
-
@synchronicity = @options[:
|
30
|
+
@synchronicity = @options[:process_sync]
|
31
31
|
start_running
|
32
32
|
end
|
33
33
|
|
34
34
|
def start_running
|
35
35
|
setup_attributes
|
36
36
|
run_right_popen3
|
37
|
-
setup_em_error_handler
|
37
|
+
setup_em_error_handler
|
38
38
|
end
|
39
39
|
|
40
40
|
def setup_attributes
|
@@ -63,9 +63,9 @@ module CapistranoMulticonfigParallel
|
|
63
63
|
log_to_file("worker #{@job_id} startsnotify finished with exit status #{exit_status.inspect}")
|
64
64
|
if @actor.present? && @actor.respond_to?(:notify_finished)
|
65
65
|
if @actor.respond_to?(:async) && @synchronicity == :async
|
66
|
-
@actor.async.notify_finished(exit_status)
|
67
|
-
|
68
|
-
@actor.notify_finished(exit_status)
|
66
|
+
@actor.async.notify_finished(exit_status, @runner_status)
|
67
|
+
else
|
68
|
+
@actor.notify_finished(exit_status, @runner_status)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -96,7 +96,6 @@ module CapistranoMulticonfigParallel
|
|
96
96
|
|
97
97
|
def run_right_popen3_sync(command, popen3_options)
|
98
98
|
do_right_popen3_sync(command, popen3_options)
|
99
|
-
sleep(0.1) until @runner_status.exit_status.present?
|
100
99
|
end
|
101
100
|
|
102
101
|
def run_right_popen3_async(command, popen3_options)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative './runner_status'
|
2
|
+
module CapistranoMulticonfigParallel
|
3
|
+
# class that is used to execute the capistrano tasks and it is invoked by the celluloid worker
|
4
|
+
class BundlerStatus < CapistranoMulticonfigParallel::RunnerStatus
|
5
|
+
|
6
|
+
def on_read_stdout(data)
|
7
|
+
show_bundler_progress(data)
|
8
|
+
super(data)
|
9
|
+
end
|
10
|
+
|
11
|
+
def show_bundler_progress(data)
|
12
|
+
data = data.strip
|
13
|
+
return if data.blank? || data == '.'
|
14
|
+
if @actor.present? && @actor.respond_to?(:show_bundler_progress)
|
15
|
+
call_bundler_progress(data)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def call_bundler_progress(data)
|
20
|
+
if @actor.respond_to?(:async)
|
21
|
+
@actor.async.show_bundler_progress(data)
|
22
|
+
else
|
23
|
+
@actor.show_bundler_progress(data)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -15,9 +15,11 @@ module CapistranoMulticonfigParallel
|
|
15
15
|
@options = options.stringify_keys
|
16
16
|
@application = application
|
17
17
|
@manager = @application.manager
|
18
|
-
@gitflow ||= command.gitflow_enabled?
|
19
18
|
end
|
20
19
|
|
20
|
+
def gitflow
|
21
|
+
@gitflow ||= command.gitflow_enabled?
|
22
|
+
end
|
21
23
|
|
22
24
|
def save_stderr_error(data)
|
23
25
|
return unless development_debug?
|
@@ -111,7 +113,6 @@ module CapistranoMulticonfigParallel
|
|
111
113
|
|
112
114
|
def setup_additional_env_variables(value)
|
113
115
|
value["#{env_variable}"] = id
|
114
|
-
value["capistrano_version"] = job_capistrano_version
|
115
116
|
end
|
116
117
|
|
117
118
|
def finished?
|
@@ -126,6 +127,11 @@ module CapistranoMulticonfigParallel
|
|
126
127
|
['deploy:rollback'].include?(action)
|
127
128
|
end
|
128
129
|
|
130
|
+
def mark_for_dispatching_new_job
|
131
|
+
return if rolling_back?
|
132
|
+
will_dispatch_new_job = new_jobs_dispatched.size + 1
|
133
|
+
end
|
134
|
+
|
129
135
|
def marked_for_dispatching_new_job?
|
130
136
|
will_dispatch_new_job.to_i != new_jobs_dispatched.size
|
131
137
|
end
|
@@ -12,14 +12,13 @@ module CapistranoMulticonfigParallel
|
|
12
12
|
def initialize(job)
|
13
13
|
@job = job
|
14
14
|
@job_final_gemfile = job_gemfile_multi
|
15
|
-
@legacy_capistrano = legacy_capistrano? ? true : false
|
16
15
|
end
|
17
16
|
|
18
17
|
def lockfile_parser
|
19
18
|
if File.exists?(job_gemfile) && File.exists?(job_gemfile_lock)
|
20
19
|
@lockfile_parser ||= Bundler::LockfileParser.new(Bundler.read_file("#{job_gemfile_lock}"))
|
21
20
|
else
|
22
|
-
raise
|
21
|
+
raise "please install the gems separately for this application #{job_path} and re-try again!"
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
@@ -28,12 +27,12 @@ module CapistranoMulticonfigParallel
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def fetch_bundler_worker_command
|
31
|
-
get_command_script(fetch_bundler_check_command)
|
30
|
+
get_command_script(fetch_bundler_check_command, "bundler")
|
32
31
|
end
|
33
32
|
|
34
33
|
|
35
34
|
def find_capfile(custom_path = job_path)
|
36
|
-
@capfile_path ||=
|
35
|
+
@capfile_path ||= find_file_by_names(custom_path, 'capfile').first
|
37
36
|
end
|
38
37
|
|
39
38
|
def capfile_name
|
@@ -109,13 +108,13 @@ module CapistranoMulticonfigParallel
|
|
109
108
|
array_options = []
|
110
109
|
filtered_keys = options.delete(:filtered_keys) || []
|
111
110
|
env_options.each do |key, value|
|
112
|
-
array_options << "#{env_prefix(key,
|
111
|
+
array_options << "#{env_prefix(key, legacy_capistrano)} #{env_key_format(key, legacy_capistrano)}=#{value}" if value.present? && !env_option_filtered?(key, filtered_keys)
|
113
112
|
end
|
114
113
|
setup_remaining_flags(array_options, options)
|
115
114
|
end
|
116
115
|
|
117
116
|
def setup_remaining_flags(array_options, options)
|
118
|
-
array_options << trace_flag(
|
117
|
+
array_options << trace_flag(legacy_capistrano) if app_debug_enabled?
|
119
118
|
array_options.concat(setup_flags_for_job(options))
|
120
119
|
end
|
121
120
|
|
@@ -128,10 +127,14 @@ module CapistranoMulticonfigParallel
|
|
128
127
|
@job_capistrano_version ||= job_gem_version("capistrano")
|
129
128
|
end
|
130
129
|
|
131
|
-
def
|
130
|
+
def legacy_capistrano_version?
|
132
131
|
verify_gem_version(job_capistrano_version, '3.0', operator: '<')
|
133
132
|
end
|
134
133
|
|
134
|
+
def legacy_capistrano
|
135
|
+
@legacy_capistrano ||= legacy_capistrano_version? ? true : false
|
136
|
+
end
|
137
|
+
|
135
138
|
def capistrano_sentinel_needs_updating?
|
136
139
|
if capistrano_sentinel_available?
|
137
140
|
loaded_capistrano_sentinel_version == job_capistrano_sentinel_version
|
@@ -198,7 +201,15 @@ module CapistranoMulticonfigParallel
|
|
198
201
|
rvm_enabled_for_job? ? "bash --login -c '#{command}'" : command
|
199
202
|
end
|
200
203
|
|
201
|
-
def
|
204
|
+
def log_to_worker(message, action = nil)
|
205
|
+
if action.present? || action.to_s == id.to_s
|
206
|
+
log_to_file(message, job_id: id, prefix: action)
|
207
|
+
else
|
208
|
+
log_to_file(message)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def get_command_script(command, action = nil)
|
202
213
|
command = rvm_bash_prefix(command)
|
203
214
|
command = command.inspect
|
204
215
|
command_text =<<-CMD
|
@@ -211,13 +222,13 @@ module CapistranoMulticonfigParallel
|
|
211
222
|
|
212
223
|
if rvm_enabled_for_job?
|
213
224
|
create_job_tempfile_command(command_text)
|
214
|
-
|
225
|
+
log_to_worker("JOB #{@job_id} created Tempfile #{@tempfile.path} with contents #{File.read(@tempfile.path)}", action)
|
215
226
|
"ruby #{@tempfile.path}"
|
216
227
|
else
|
217
228
|
final_command=<<-CMD
|
218
229
|
cd #{job_path} && bundle exec ruby -e "#{command_text}"
|
219
230
|
CMD
|
220
|
-
|
231
|
+
log_to_worker("JOB #{@job_id} prepared command #{final_command}", action)
|
221
232
|
final_command
|
222
233
|
end
|
223
234
|
end
|
@@ -250,12 +261,15 @@ module CapistranoMulticonfigParallel
|
|
250
261
|
end
|
251
262
|
|
252
263
|
def prepare_application_for_deployment
|
253
|
-
|
254
|
-
|
255
|
-
|
264
|
+
config = @job.application.patched_job_paths.find{|hash| hash[:path] == job_path}
|
265
|
+
if config.present?
|
266
|
+
@job_final_gemfile = config[:gemfile]
|
267
|
+
@job_final_capfile = config[:capfile]
|
268
|
+
else
|
269
|
+
check_capistrano_sentinel_availability
|
270
|
+
prepare_capfile
|
271
|
+
@job.application.patched_job_paths << {path: job_path, gemfile: @job_final_gemfile, capfile: @job_final_capfile}
|
256
272
|
end
|
257
|
-
check_capistrano_sentinel_availability
|
258
|
-
prepare_capfile
|
259
273
|
end
|
260
274
|
|
261
275
|
def check_capistrano_sentinel_availability
|
@@ -307,17 +321,7 @@ module CapistranoMulticonfigParallel
|
|
307
321
|
def rollback_changes_to_application
|
308
322
|
FileUtils.rm_rf(job_gemfile_multi) if File.exists?(job_gemfile_multi)
|
309
323
|
FileUtils.rm_rf("#{job_gemfile_multi}.lock") if File.exists?("#{job_gemfile_multi}.lock")
|
310
|
-
|
311
|
-
File.open(job_capfile, 'r') do |f|
|
312
|
-
File.open("#{job_capfile}.tmp", 'w') do |f2|
|
313
|
-
f.each_line do |line|
|
314
|
-
f2.write(line) unless line.include?(capistrano_sentinel_name)
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
318
|
-
FileUtils.mv "#{job_capfile}.tmp", job_capfile
|
319
|
-
FileUtils.rm_rf("#{job_capfile}.tmp")
|
320
|
-
end
|
324
|
+
FileUtils.rm_rf(job_capfile_multi) if File.exists?(job_capfile_multi)
|
321
325
|
FileUtils.rm_rf(@tempfile.path) if defined?(@tempfile) && @tempfile
|
322
326
|
end
|
323
327
|
|
@@ -331,7 +335,7 @@ module CapistranoMulticonfigParallel
|
|
331
335
|
private
|
332
336
|
|
333
337
|
def run_shell_command(command)
|
334
|
-
|
338
|
+
Kernel.system("#{command}")
|
335
339
|
end
|
336
340
|
end
|
337
341
|
end
|
@@ -52,49 +52,59 @@ module CapistranoMulticonfigParallel
|
|
52
52
|
@async_exception = nil
|
53
53
|
end
|
54
54
|
|
55
|
+
def log_to_worker(message, io = nil)
|
56
|
+
if io.present?
|
57
|
+
log_to_file("#{io.upcase} ---- #{message}", job_id: @job_id, prefix: @options[:log_prefix])
|
58
|
+
elsif @options[:log_prefix].present?
|
59
|
+
log_to_file(message, job_id: @job_id, prefix: @options[:log_prefix])
|
60
|
+
else
|
61
|
+
log_to_file(message)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
55
65
|
def on_pid(pid)
|
56
|
-
|
66
|
+
log_to_worker"Child process for worker #{@job_id} on_pid #{pid.inspect}"
|
57
67
|
@pid ||= pid
|
58
68
|
end
|
59
69
|
|
60
70
|
|
61
71
|
def on_input_stdin(data)
|
62
|
-
|
63
|
-
|
72
|
+
log_to_worker(data, "stdin")
|
73
|
+
@output_text << data
|
64
74
|
end
|
65
75
|
|
66
76
|
def on_read_stdout(data)
|
67
|
-
|
77
|
+
log_to_worker(data, "stdout")
|
68
78
|
@output_text << data
|
69
79
|
end
|
70
80
|
|
71
81
|
def on_read_stderr(data)
|
72
|
-
|
82
|
+
log_to_worker(data, "stderr")
|
73
83
|
@error_text << data
|
74
84
|
end
|
75
85
|
|
76
86
|
|
77
87
|
def on_timeout
|
78
|
-
|
88
|
+
log_to_worker "Child process for worker #{@job_id} on_timeout disconnected"
|
79
89
|
@did_timeout = true
|
80
|
-
@callback.call(self) if @callback && @expect_timeout
|
90
|
+
@callback.call(self) if @callback && process_runner.synchronicity == :sync && @expect_timeout
|
81
91
|
end
|
82
92
|
|
83
93
|
def on_size_limit
|
84
|
-
|
94
|
+
log_to_worker "Child process for worker #{@job_id} on_size_limit disconnected"
|
85
95
|
@did_size_limit = true
|
86
|
-
@callback.call(self) if
|
96
|
+
@callback.call(self) if @callback && process_runner.synchronicity == :sync && @expect_size_limit
|
87
97
|
end
|
88
98
|
|
89
99
|
def on_exit(status)
|
90
|
-
|
100
|
+
log_to_worker "Child process for worker #{@job_id} on_exit disconnected due to #{status.inspect}"
|
91
101
|
@exit_status = status.exitstatus
|
92
|
-
@callback.call(self) if @callback
|
102
|
+
@callback.call(self) if @callback && process_runner.synchronicity == :sync
|
93
103
|
end
|
94
104
|
|
95
105
|
def async_exception_handler(async_exception)
|
96
106
|
@async_exception = async_exception
|
97
|
-
|
107
|
+
log_to_worker "Child process for worker #{@job_id} async_exception_handler disconnected due to error #{data.inspect}"
|
98
108
|
@exit_status = 1
|
99
109
|
end
|
100
110
|
|
@@ -84,7 +84,7 @@ module CapistranoMulticonfigParallel
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def log_to_file(message, options = {})
|
87
|
-
worker_log = options.fetch(:job_id, '').present? ? find_worker_log(options[:job_id]) : logger
|
87
|
+
worker_log = options.fetch(:job_id, '').present? ? find_worker_log(options[:job_id], options[:prefix]) : logger
|
88
88
|
print_to_log_file(worker_log, options.merge(message: message)) if worker_log.present? && app_debug_enabled?
|
89
89
|
end
|
90
90
|
|
@@ -94,10 +94,10 @@ module CapistranoMulticonfigParallel
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
def find_worker_log(job_id)
|
97
|
+
def find_worker_log(job_id, prefix = nil)
|
98
98
|
return if job_id.blank?
|
99
99
|
FileUtils.mkdir_p(log_directory) unless File.directory?(log_directory)
|
100
|
-
filename = File.join(log_directory, "
|
100
|
+
filename = File.join(log_directory, "multi_cap_worker_#{prefix.present? ? "#{prefix}_" : ''}#{job_id}.log")
|
101
101
|
setup_filename_logger(filename)
|
102
102
|
end
|
103
103
|
|
@@ -125,6 +125,15 @@ module CapistranoMulticonfigParallel
|
|
125
125
|
root.children.find { |file| check_file(file, filename) }.present? || pathname_is_root?(root)
|
126
126
|
end
|
127
127
|
|
128
|
+
def find_file_by_names(custom_path = detect_root, names = ['capfile'])
|
129
|
+
names = names.is_a?(Array) ? names : [names]
|
130
|
+
pathnames = names.collect do |name|
|
131
|
+
Pathname.new(custom_path).children.find { |file| check_file(file, name) }
|
132
|
+
end
|
133
|
+
pathnames.present? && pathnames.is_a?(Array) ? pathnames.compact : pathnames
|
134
|
+
end
|
135
|
+
|
136
|
+
|
128
137
|
def try_detect_file(filename = 'capfile')
|
129
138
|
root = pwd_parent_dir
|
130
139
|
root = root.parent until find_file_in_directory(root, filename)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano_multiconfig_parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
@@ -258,6 +258,26 @@ dependencies:
|
|
258
258
|
- - ">="
|
259
259
|
- !ruby/object:Gem::Version
|
260
260
|
version: 0.0.16
|
261
|
+
- !ruby/object:Gem::Dependency
|
262
|
+
name: ruby-progressbar
|
263
|
+
requirement: !ruby/object:Gem::Requirement
|
264
|
+
requirements:
|
265
|
+
- - "~>"
|
266
|
+
- !ruby/object:Gem::Version
|
267
|
+
version: '1.8'
|
268
|
+
- - ">="
|
269
|
+
- !ruby/object:Gem::Version
|
270
|
+
version: 1.8.1
|
271
|
+
type: :runtime
|
272
|
+
prerelease: false
|
273
|
+
version_requirements: !ruby/object:Gem::Requirement
|
274
|
+
requirements:
|
275
|
+
- - "~>"
|
276
|
+
- !ruby/object:Gem::Version
|
277
|
+
version: '1.8'
|
278
|
+
- - ">="
|
279
|
+
- !ruby/object:Gem::Version
|
280
|
+
version: 1.8.1
|
261
281
|
- !ruby/object:Gem::Dependency
|
262
282
|
name: rake
|
263
283
|
requirement: !ruby/object:Gem::Requirement
|
@@ -491,6 +511,7 @@ files:
|
|
491
511
|
- lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb
|
492
512
|
- lib/capistrano_multiconfig_parallel/celluloid/terminal_table.rb
|
493
513
|
- lib/capistrano_multiconfig_parallel/celluloid/web_server.rb
|
514
|
+
- lib/capistrano_multiconfig_parallel/classes/bundler_status.rb
|
494
515
|
- lib/capistrano_multiconfig_parallel/classes/child_process_status.rb
|
495
516
|
- lib/capistrano_multiconfig_parallel/classes/cursor.rb
|
496
517
|
- lib/capistrano_multiconfig_parallel/classes/dependency_tracker.rb
|