capistrano_multiconfig_parallel 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/capistrano_multiconfig_parallel/application.rb +1 -5
- data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_manager.rb +3 -2
- data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb +3 -7
- data/lib/capistrano_multiconfig_parallel/celluloid/child_process.rb +10 -0
- data/lib/capistrano_multiconfig_parallel/classes/job.rb +11 -1
- data/lib/capistrano_multiconfig_parallel/classes/job_command.rb +1 -1
- data/lib/capistrano_multiconfig_parallel/classes/rake_task_hooks.rb +13 -6
- data/lib/capistrano_multiconfig_parallel/cli.rb +4 -3
- data/lib/capistrano_multiconfig_parallel/helpers/capistrano_helper.rb +2 -2
- data/lib/capistrano_multiconfig_parallel/helpers/core_helper.rb +1 -1
- data/lib/capistrano_multiconfig_parallel/helpers/internal_helper.rb +1 -1
- data/lib/capistrano_multiconfig_parallel/initializers/capistrano2.rb +7 -5
- data/lib/capistrano_multiconfig_parallel/initializers/rake.rb +1 -1
- data/lib/capistrano_multiconfig_parallel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26035c748d3494c6c5159791823939332b62f001
|
4
|
+
data.tar.gz: 53592e1501a707b02dbf946a7debb71827f8b9f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b680cf811f4dd24cf7374cb69c18ffb25a1335f307b7172c47e85d086c48198ced14301cb7c188050ec242fcdf3b2c85804dbf030da034f02d03dfe76fc5d0a
|
7
|
+
data.tar.gz: 1a746e0c0116857eed89bdfa92b913171858fe6c2fecdaf42cb6be25f74b2d5d1687d91ef02e22d5112992f7d7c4281a6edce03b2b70a2c47414bbe8668c1102
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ IMPORTANT! The whole reason for this gem was for using [Caphub](https://github.c
|
|
17
17
|
|
18
18
|
CAUTION!! PLEASE READ CAREFULLY!! Capistrano is not thread-safe. However in order to work around this problem, each of the task is executing inside a thread that spawns a new process in order to run capistrano tasks The thread monitors the process. This works well, however if the tasks you are executing is working with files, you might get into deadlocks because multiple proceses try to access same resource. Instead of using files , please consider using StringIO instead.
|
19
19
|
|
20
|
-
NEW Improvements in version 1.0.
|
20
|
+
NEW Improvements in version 1.0.5
|
21
21
|
---------------------------------
|
22
22
|
|
23
23
|
- added support for Capistrano version 2 (Capistrano 3 was already supported)
|
@@ -48,11 +48,7 @@ module CapistranoMulticonfigParallel
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def custom_command?
|
51
|
-
|
52
|
-
!stages.include?(@top_level_tasks.first) && custom_commands.include?(@top_level_tasks.first)
|
53
|
-
else
|
54
|
-
!stages.include?(@top_level_tasks.second) && stages.include?(@top_level_tasks.first) && custom_commands.include?(@top_level_tasks.second)
|
55
|
-
end
|
51
|
+
custom_commands.include?(@top_level_tasks.first)
|
56
52
|
end
|
57
53
|
|
58
54
|
def multi_apps?
|
@@ -10,7 +10,7 @@ module CapistranoMulticonfigParallel
|
|
10
10
|
include Celluloid::Logger
|
11
11
|
include CapistranoMulticonfigParallel::ApplicationHelper
|
12
12
|
|
13
|
-
attr_accessor :jobs, :job_to_worker, :worker_to_job, :job_to_condition, :mutex, :registration_complete, :workers_terminated
|
13
|
+
attr_accessor :jobs, :job_to_worker, :worker_to_job, :job_to_condition, :mutex, :registration_complete, :workers_terminated, :stderr_buffer
|
14
14
|
|
15
15
|
attr_reader :worker_supervisor, :workers
|
16
16
|
trap_exit :worker_died
|
@@ -33,6 +33,7 @@ module CapistranoMulticonfigParallel
|
|
33
33
|
# Get a handle on the PoolManager
|
34
34
|
# http://rubydoc.info/gems/celluloid/Celluloid/PoolManager
|
35
35
|
# @workers = workers_pool.actor
|
36
|
+
@stderr_buffer = StringIO.new
|
36
37
|
@conditions = []
|
37
38
|
@jobs = {}
|
38
39
|
@job_to_worker = {}
|
@@ -188,7 +189,7 @@ module CapistranoMulticonfigParallel
|
|
188
189
|
|
189
190
|
def can_tag_staging?
|
190
191
|
@job_manager.can_tag_staging? &&
|
191
|
-
@jobs.find { |_job_id, job| job
|
192
|
+
@jobs.find { |_job_id, job| job.stage == 'production' }.blank?
|
192
193
|
end
|
193
194
|
|
194
195
|
def dispatch_new_job(job, options = {})
|
@@ -95,13 +95,9 @@ module CapistranoMulticonfigParallel
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def check_child_proces
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
else
|
102
|
-
@client.unsubscribe("rake_worker_#{@job_id}_count")
|
103
|
-
@child_process.exit_status = nil
|
104
|
-
end
|
98
|
+
@child_process = CapistranoMulticonfigParallel::ChildProcess.new
|
99
|
+
Actor.current.link @child_process
|
100
|
+
@child_process
|
105
101
|
end
|
106
102
|
|
107
103
|
def on_close(code, reason)
|
@@ -62,10 +62,19 @@ module CapistranoMulticonfigParallel
|
|
62
62
|
return if @exit_status.blank?
|
63
63
|
@timer.cancel
|
64
64
|
@job.exit_status = @exit_status
|
65
|
+
print_error_if_exist
|
65
66
|
log_to_file("worker #{@job_id} startsnotify finished with exit status #{@exit_status.inspect}")
|
66
67
|
@actor.async.notify_finished(@exit_status)
|
67
68
|
end
|
68
69
|
|
70
|
+
def print_error_if_exist
|
71
|
+
[@job.stderr_buffer].each do |buffer|
|
72
|
+
buffer.rewind
|
73
|
+
data = buffer.read
|
74
|
+
log_output_error(nil, 'stderr', "Child process for worker #{@job_id} died for reason: #{data}") if data.present?
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
69
78
|
def start_async_deploy
|
70
79
|
RightScale::RightPopen.popen3_async(
|
71
80
|
@cmd,
|
@@ -93,6 +102,7 @@ module CapistranoMulticonfigParallel
|
|
93
102
|
end
|
94
103
|
|
95
104
|
def on_read_stderr(data)
|
105
|
+
@job.save_stderr_error(data)
|
96
106
|
io_callback('stderr', data)
|
97
107
|
end
|
98
108
|
|
@@ -5,7 +5,7 @@ module CapistranoMulticonfigParallel
|
|
5
5
|
class Job
|
6
6
|
include CapistranoMulticonfigParallel::ApplicationHelper
|
7
7
|
|
8
|
-
attr_reader :options
|
8
|
+
attr_reader :options, :application, :manager
|
9
9
|
attr_writer :status, :exit_status
|
10
10
|
|
11
11
|
delegate :job_stage,
|
@@ -15,12 +15,22 @@ module CapistranoMulticonfigParallel
|
|
15
15
|
:setup_command_line,
|
16
16
|
to: :command
|
17
17
|
|
18
|
+
delegate :stderr_buffer,
|
19
|
+
to: :manager
|
20
|
+
|
18
21
|
def initialize(application, options)
|
19
22
|
@options = options.stringify_keys
|
20
23
|
@application = application
|
21
24
|
@manager = @application.manager
|
22
25
|
end
|
23
26
|
|
27
|
+
def save_stderr_error(data)
|
28
|
+
stderr_buffer.rewind
|
29
|
+
old_data = stderr_buffer.read.dup
|
30
|
+
new_data = old_data.to_s + data
|
31
|
+
stderr_buffer.write(new_data) if new_data.include?('aborted!')
|
32
|
+
end
|
33
|
+
|
24
34
|
def env_variable
|
25
35
|
CapistranoMulticonfigParallel::ENV_KEY_JOB_ID
|
26
36
|
end
|
@@ -33,7 +33,7 @@ module CapistranoMulticonfigParallel
|
|
33
33
|
def setup_env_options(options = {})
|
34
34
|
array_options = []
|
35
35
|
env_options.each do |key, value|
|
36
|
-
array_options << "#{env_prefix} #{env_key_format(key)}=#{value}" if value.present? && !env_option_filtered?(key, options.fetch(:filtered_keys, []))
|
36
|
+
array_options << "#{env_prefix(key)} #{env_key_format(key)}=#{value}" if value.present? && !env_option_filtered?(key, options.fetch(:filtered_keys, []))
|
37
37
|
end
|
38
38
|
array_options << trace_flag if app_debug_enabled?
|
39
39
|
array_options
|
@@ -7,10 +7,9 @@ module CapistranoMulticonfigParallel
|
|
7
7
|
class RakeTaskHooks
|
8
8
|
include CapistranoMulticonfigParallel::ApplicationHelper
|
9
9
|
attr_accessor :task, :env, :config
|
10
|
-
def initialize(
|
11
|
-
@env =
|
10
|
+
def initialize(task)
|
11
|
+
@env = CapistranoMulticonfigParallel.original_args_hash
|
12
12
|
@task = task.respond_to?(:fully_qualified_name) ? task.fully_qualified_name : task
|
13
|
-
@config = config
|
14
13
|
end
|
15
14
|
|
16
15
|
def automatic_hooks(&block)
|
@@ -23,12 +22,20 @@ module CapistranoMulticonfigParallel
|
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
|
-
def
|
27
|
-
|
25
|
+
def print_question?(question)
|
26
|
+
if job_id.present?
|
27
|
+
actor.user_prompt_needed?(question)
|
28
|
+
else
|
29
|
+
yield if block.given?
|
30
|
+
end
|
28
31
|
end
|
29
32
|
|
30
33
|
private
|
31
34
|
|
35
|
+
def actor
|
36
|
+
Celluloid::Actor[rake_actor_id]
|
37
|
+
end
|
38
|
+
|
32
39
|
def output_stream
|
33
40
|
CapistranoMulticonfigParallel::OutputStream
|
34
41
|
end
|
@@ -70,7 +77,7 @@ module CapistranoMulticonfigParallel
|
|
70
77
|
end
|
71
78
|
|
72
79
|
def job_id
|
73
|
-
|
80
|
+
@env.fetch(CapistranoMulticonfigParallel::ENV_KEY_JOB_ID, nil)
|
74
81
|
end
|
75
82
|
|
76
83
|
def rake_actor_id
|
@@ -10,14 +10,15 @@ module CapistranoMulticonfigParallel
|
|
10
10
|
before_start
|
11
11
|
arguments = multi_fetch_argv(original_args)
|
12
12
|
configuration_valid?
|
13
|
-
execute_start(arguments)
|
13
|
+
execute_start(arguments[CapistranoMulticonfigParallel::ENV_KEY_JOB_ID])
|
14
14
|
end
|
15
15
|
|
16
|
-
def execute_start(
|
17
|
-
if
|
16
|
+
def execute_start(job_id)
|
17
|
+
if job_id.blank?
|
18
18
|
run_the_application
|
19
19
|
else
|
20
20
|
ARGV.reject! { |arg| arg_is_in_default_config?(arg) }
|
21
|
+
log_to_file("worker #{job_id} runs with ARGV #{ARGV.inspect}", job_id: job_id)
|
21
22
|
run_capistrano
|
22
23
|
end
|
23
24
|
end
|
@@ -7,8 +7,8 @@ module CapistranoMulticonfigParallel
|
|
7
7
|
capistrano_version_2? ? keys.map(&:downcase) : keys
|
8
8
|
end
|
9
9
|
|
10
|
-
def env_prefix
|
11
|
-
capistrano_version_2? ? '-S' : ''
|
10
|
+
def env_prefix(key)
|
11
|
+
key != CapistranoMulticonfigParallel::ENV_KEY_JOB_ID && capistrano_version_2? ? '-S' : ''
|
12
12
|
end
|
13
13
|
|
14
14
|
def env_key_format(key)
|
@@ -67,7 +67,7 @@ module CapistranoMulticonfigParallel
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def log_output_error(error, output, message)
|
70
|
-
return if error_filtered?(error)
|
70
|
+
return if message.blank? || error_filtered?(error)
|
71
71
|
puts message if output.present?
|
72
72
|
terminal_actor.errors.push(message) if terminal_errors?
|
73
73
|
end
|
@@ -30,7 +30,7 @@ module CapistranoMulticonfigParallel
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def default_config_keys
|
33
|
-
default_internal_config.map { |array| array[0].to_s }
|
33
|
+
default_internal_config.map { |array| array[0].to_s }.concat([CapistranoMulticonfigParallel::ENV_KEY_JOB_ID])
|
34
34
|
end
|
35
35
|
|
36
36
|
def arg_is_in_default_config?(arg)
|
@@ -4,9 +4,11 @@ if CapistranoMulticonfigParallel.capistrano_version_2?
|
|
4
4
|
HighLine.class_eval do
|
5
5
|
alias_method :original_ask, :ask
|
6
6
|
|
7
|
-
def ask(question,
|
8
|
-
rake = CapistranoMulticonfigParallel::RakeTaskHooks.new(
|
9
|
-
rake.
|
7
|
+
def ask(question, answer_type = String, &details)
|
8
|
+
rake = CapistranoMulticonfigParallel::RakeTaskHooks.new(nil)
|
9
|
+
rake.print_question?(question) do
|
10
|
+
original_ask(question, answer_type, &details)
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
@@ -14,7 +16,7 @@ if CapistranoMulticonfigParallel.capistrano_version_2?
|
|
14
16
|
alias_method :original_execute_task, :execute_task
|
15
17
|
|
16
18
|
def execute_task(task)
|
17
|
-
rake = CapistranoMulticonfigParallel::RakeTaskHooks.new(
|
19
|
+
rake = CapistranoMulticonfigParallel::RakeTaskHooks.new(task)
|
18
20
|
rake.automatic_hooks do
|
19
21
|
original_execute_task(task)
|
20
22
|
end
|
@@ -25,7 +27,7 @@ if CapistranoMulticonfigParallel.capistrano_version_2?
|
|
25
27
|
alias_method :original_trigger, :trigger
|
26
28
|
|
27
29
|
def trigger(event, task = nil)
|
28
|
-
rake = CapistranoMulticonfigParallel::RakeTaskHooks.new(
|
30
|
+
rake = CapistranoMulticonfigParallel::RakeTaskHooks.new(task)
|
29
31
|
rake.automatic_hooks do
|
30
32
|
original_trigger(event, task)
|
31
33
|
end
|
@@ -3,7 +3,7 @@ Rake::Task.class_eval do
|
|
3
3
|
alias_method :original_execute, :execute
|
4
4
|
|
5
5
|
def execute(*args)
|
6
|
-
rake = CapistranoMulticonfigParallel::RakeTaskHooks.new(
|
6
|
+
rake = CapistranoMulticonfigParallel::RakeTaskHooks.new(self)
|
7
7
|
rake.automatic_hooks do
|
8
8
|
original_execute(*args)
|
9
9
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano_multiconfig_parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid-pmap
|