capistrano_multiconfig_parallel 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/capistrano_multiconfig_parallel/all.rb +1 -0
- data/lib/capistrano_multiconfig_parallel/base.rb +4 -4
- data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb +1 -9
- data/lib/capistrano_multiconfig_parallel/celluloid/rake_worker.rb +3 -3
- data/lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb +1 -0
- data/lib/capistrano_multiconfig_parallel/classes/cursor.rb +1 -1
- data/lib/capistrano_multiconfig_parallel/classes/job.rb +2 -1
- data/lib/capistrano_multiconfig_parallel/classes/job_command.rb +33 -4
- data/lib/capistrano_multiconfig_parallel/classes/rake_task_hooks.rb +7 -6
- data/lib/capistrano_multiconfig_parallel/helpers/application_helper.rb +17 -9
- data/lib/capistrano_multiconfig_parallel/helpers/capistrano_helper.rb +4 -4
- data/lib/capistrano_multiconfig_parallel/helpers/configuration.rb +8 -2
- data/lib/capistrano_multiconfig_parallel/helpers/internal_helper.rb +17 -1
- data/lib/capistrano_multiconfig_parallel/version.rb +2 -2
- 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: 91eff916dbb3076e8afd788b6b853dedf839a523
|
4
|
+
data.tar.gz: 7056e86b82f6d3021c3e8778e86d5c33cd9a7543
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99d5dad8951a1f901a94f49e6f4ac7c6781555e218ccfe4f5f152b71160fa37d7824ab649e56b0d47abfc9588fc264ee5d460186e0571109e77ea8e22fa4a945
|
7
|
+
data.tar.gz: f93cc40a17d86fa045e624f06f4fb8716632867cf7df0761c52d313eaed40dae304249c4e989ccf4fda7da29045516a5a1c2ae8aa25803cb1bb00bacbd5991be
|
@@ -29,14 +29,14 @@ module CapistranoMulticonfigParallel
|
|
29
29
|
set_celluloid_exception_handling
|
30
30
|
end
|
31
31
|
|
32
|
-
def original_args_hash
|
33
|
-
multi_fetch_argv((original_args || ARGV).dup)
|
34
|
-
end
|
35
|
-
|
36
32
|
def job_id
|
37
33
|
original_args_hash.fetch(CapistranoMulticonfigParallel::ENV_KEY_JOB_ID, nil)
|
38
34
|
end
|
39
35
|
|
36
|
+
def original_args_hash
|
37
|
+
multi_fetch_argv((original_args || ARGV).dup)
|
38
|
+
end
|
39
|
+
|
40
40
|
def capistrano_version
|
41
41
|
find_loaded_gem_property('capistrano', 'version')
|
42
42
|
end
|
@@ -121,14 +121,6 @@ module CapistranoMulticonfigParallel
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
def message_is_for_stdout?(message)
|
125
|
-
message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['action'] == 'stdout'
|
126
|
-
end
|
127
|
-
|
128
|
-
def message_is_about_a_task?(message)
|
129
|
-
message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['task'].present?
|
130
|
-
end
|
131
|
-
|
132
124
|
def executed_task?(task)
|
133
125
|
rake_tasks.present? && rake_tasks.index(task.to_s).present?
|
134
126
|
end
|
@@ -163,7 +155,7 @@ module CapistranoMulticonfigParallel
|
|
163
155
|
|
164
156
|
def finish_worker(exit_status)
|
165
157
|
log_to_file("worker #{job_id} tries to terminate with exit_status #{exit_status}")
|
166
|
-
@manager.mark_completed_remaining_tasks(@job)
|
158
|
+
@manager.mark_completed_remaining_tasks(@job) if Actor.current.alive?
|
167
159
|
update_machine_state('FINISHED') if exit_status == 0
|
168
160
|
@manager.workers_terminated.signal('completed') if @manager.present? && @manager.alive? && @manager.all_workers_finished?
|
169
161
|
end
|
@@ -17,7 +17,7 @@ module CapistranoMulticonfigParallel
|
|
17
17
|
|
18
18
|
def custom_attributes
|
19
19
|
@publisher_channel = "worker_#{@job_id}"
|
20
|
-
@action = 'invoke'
|
20
|
+
@action = @options['action'].present? ? @options['action'] : 'invoke'
|
21
21
|
@task = @options['task']
|
22
22
|
end
|
23
23
|
|
@@ -72,7 +72,7 @@ module CapistranoMulticonfigParallel
|
|
72
72
|
log_to_file("Rake worker #{@job_id} received after on message:", message)
|
73
73
|
if @client.succesfull_subscription?(message)
|
74
74
|
publish_subscription_successfull(message)
|
75
|
-
elsif
|
75
|
+
elsif message_is_about_a_task?(message)
|
76
76
|
task_approval(message)
|
77
77
|
elsif msg_for_stdin?(message)
|
78
78
|
stdin_approval(message)
|
@@ -105,7 +105,7 @@ module CapistranoMulticonfigParallel
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def task_approval(message)
|
108
|
-
return unless
|
108
|
+
return unless message_is_about_a_task?(message)
|
109
109
|
if @job_id == message['job_id'] && message['task'].to_s == task_name.to_s && message['approved'] == 'yes'
|
110
110
|
@task_approved = true
|
111
111
|
else
|
@@ -45,6 +45,7 @@ module CapistranoMulticonfigParallel
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def actor_notify_state_change(current_state, event, new_state)
|
48
|
+
return unless @actor.alive?
|
48
49
|
@actor.send_msg(CapistranoMulticonfigParallel::TerminalTable.topic, type: 'event', new_state: new_state, message: "Going from #{current_state} to #{new_state} due to a #{event} event")
|
49
50
|
end
|
50
51
|
end
|
@@ -12,7 +12,7 @@ module CapistranoMulticonfigParallel
|
|
12
12
|
:capistrano_action,
|
13
13
|
:execute_standard_deploy,
|
14
14
|
:setup_command_line,
|
15
|
-
:
|
15
|
+
:gem_specs,
|
16
16
|
to: :command
|
17
17
|
|
18
18
|
delegate :stderr_buffer,
|
@@ -22,6 +22,7 @@ module CapistranoMulticonfigParallel
|
|
22
22
|
@options = options.stringify_keys
|
23
23
|
@application = application
|
24
24
|
@manager = @application.manager
|
25
|
+
@gitflow ||= command.gitflow_enabled?
|
25
26
|
end
|
26
27
|
|
27
28
|
def save_stderr_error(data)
|
@@ -7,19 +7,44 @@ module CapistranoMulticonfigParallel
|
|
7
7
|
include CapistranoMulticonfigParallel::ApplicationHelper
|
8
8
|
|
9
9
|
attr_reader :job, :job_capistrano_version, :legacy_capistrano
|
10
|
-
delegate :app, :stage, :action, :task_arguments, :env_options, :path, to: :job
|
10
|
+
delegate :id, :app, :stage, :action, :task_arguments, :env_options, :path, to: :job
|
11
11
|
|
12
12
|
def initialize(job)
|
13
13
|
@job = job
|
14
14
|
@legacy_capistrano = legacy_capistrano? ? true : false
|
15
15
|
end
|
16
16
|
|
17
|
+
def lockfile_parser
|
18
|
+
if File.exists?(job_gemfile_lock)
|
19
|
+
@lockfile_parser ||= Bundler::LockfileParser.new(Bundler.read_file("#{job_gemfile_lock}"))
|
20
|
+
else
|
21
|
+
raise RuntimeError, "please install the gems separately for this application #{job_path} and re-try again!"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def gem_specs
|
26
|
+
@specs = lockfile_parser.specs
|
27
|
+
end
|
28
|
+
|
29
|
+
def job_gemfile
|
30
|
+
File.join(job_path, 'Gemfile')
|
31
|
+
end
|
32
|
+
|
33
|
+
def job_gemfile_lock
|
34
|
+
File.join(job_path, 'Gemfile.lock')
|
35
|
+
end
|
36
|
+
|
37
|
+
def job_gem_version(gem_name)
|
38
|
+
gem_spec = gem_specs.find {|spec| spec.name == gem_name}
|
39
|
+
gem_spec.present? ? gem_spec.version.to_s : nil
|
40
|
+
end
|
41
|
+
|
17
42
|
def filtered_env_keys
|
18
43
|
%w(STAGES ACTION)
|
19
44
|
end
|
20
45
|
|
21
46
|
def bundle_gemfile_env
|
22
|
-
"BUNDLE_GEMFILE=#{
|
47
|
+
"BUNDLE_GEMFILE=#{job_gemfile}"
|
23
48
|
end
|
24
49
|
|
25
50
|
def gitflow
|
@@ -27,6 +52,11 @@ module CapistranoMulticonfigParallel
|
|
27
52
|
@gitflow ||= gitflow.include?('Could not find') ? false : true
|
28
53
|
end
|
29
54
|
|
55
|
+
def gitflow_enabled?
|
56
|
+
gitflow_version = job_gem_version("capistrano-gitflow")
|
57
|
+
gitflow_version.present? ? true : false
|
58
|
+
end
|
59
|
+
|
30
60
|
def job_stage
|
31
61
|
multi_apps?(job_path) && app.present? ? "#{app}:#{stage}" : "#{stage}"
|
32
62
|
end
|
@@ -60,8 +90,7 @@ module CapistranoMulticonfigParallel
|
|
60
90
|
end
|
61
91
|
|
62
92
|
def job_capistrano_version
|
63
|
-
@job_capistrano_version ||=
|
64
|
-
@job_capistrano_version = strip_characters_from_string(@job_capistrano_version)
|
93
|
+
@job_capistrano_version ||= job_gem_version("capistrano")
|
65
94
|
end
|
66
95
|
|
67
96
|
def legacy_capistrano?
|
@@ -8,13 +8,13 @@ module CapistranoMulticonfigParallel
|
|
8
8
|
include CapistranoMulticonfigParallel::ApplicationHelper
|
9
9
|
attr_accessor :job_id, :task
|
10
10
|
def initialize(task = nil)
|
11
|
-
@job_id
|
11
|
+
@job_id = CapistranoMulticonfigParallel.job_id
|
12
12
|
@task = task.respond_to?(:fully_qualified_name) ? task.fully_qualified_name : task
|
13
13
|
end
|
14
14
|
|
15
15
|
def automatic_hooks(&block)
|
16
16
|
if configuration.multi_secvential.to_s.downcase == 'false' && job_id.present? && @task.present?
|
17
|
-
actor_start_working
|
17
|
+
actor_start_working(action: 'invoke')
|
18
18
|
actor.wait_execution until actor.task_approved
|
19
19
|
actor_execute_block(&block)
|
20
20
|
else
|
@@ -26,7 +26,7 @@ module CapistranoMulticonfigParallel
|
|
26
26
|
if job_id.present?
|
27
27
|
actor.user_prompt_needed?(question)
|
28
28
|
else
|
29
|
-
yield if
|
29
|
+
yield if block_given?
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -62,12 +62,13 @@ module CapistranoMulticonfigParallel
|
|
62
62
|
after_hooks
|
63
63
|
end
|
64
64
|
|
65
|
-
def actor_start_working
|
65
|
+
def actor_start_working(additionals = {})
|
66
|
+
additionals = additionals.present? ? additionals : {}
|
66
67
|
if actor.blank?
|
67
68
|
supervise_actor
|
68
|
-
actor.work(actor_id: rake_actor_id, job_id: job_id, task: @task)
|
69
|
+
actor.work({actor_id: rake_actor_id, job_id: job_id, task: @task}.merge(additionals))
|
69
70
|
else
|
70
|
-
actor.publish_new_work(task: @task)
|
71
|
+
actor.publish_new_work({task: @task}.merge(additionals))
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -15,21 +15,29 @@ module CapistranoMulticonfigParallel
|
|
15
15
|
include CapistranoMulticonfigParallel::CapistranoHelper
|
16
16
|
|
17
17
|
delegate :logger,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
:configuration,
|
19
|
+
:configuration_valid?,
|
20
|
+
:capistrano_version_2?,
|
21
|
+
:capistrano_version,
|
22
|
+
:original_args,
|
23
|
+
to: :CapistranoMulticonfigParallel
|
24
24
|
|
25
|
-
|
25
|
+
module_function
|
26
26
|
|
27
27
|
def msg_for_stdin?(message)
|
28
28
|
message['action'] == 'stdin'
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
message['
|
31
|
+
def message_is_for_stdout?(message)
|
32
|
+
message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['action'] == 'stdout'
|
33
|
+
end
|
34
|
+
|
35
|
+
def message_is_about_a_task?(message)
|
36
|
+
message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['task'].present? && message['action'] == 'invoke'
|
37
|
+
end
|
38
|
+
|
39
|
+
def message_from_bundler?(message)
|
40
|
+
message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['task'].present? && message['action'] == 'bundle_install'
|
33
41
|
end
|
34
42
|
|
35
43
|
def get_question_details(data)
|
@@ -3,19 +3,19 @@ module CapistranoMulticonfigParallel
|
|
3
3
|
module CapistranoHelper
|
4
4
|
module_function
|
5
5
|
|
6
|
-
def filtered_env_keys_format(keys, version =
|
6
|
+
def filtered_env_keys_format(keys, version = false)
|
7
7
|
keys.map { |key| env_key_format(key, version) }
|
8
8
|
end
|
9
9
|
|
10
|
-
def env_prefix(key, version =
|
10
|
+
def env_prefix(key, version = false)
|
11
11
|
key != CapistranoMulticonfigParallel::ENV_KEY_JOB_ID && version == true ? '-S' : ''
|
12
12
|
end
|
13
13
|
|
14
|
-
def env_key_format(key, version =
|
14
|
+
def env_key_format(key, version = false)
|
15
15
|
version == true ? key.downcase : key
|
16
16
|
end
|
17
17
|
|
18
|
-
def trace_flag(version =
|
18
|
+
def trace_flag(version = false)
|
19
19
|
version == true ? '--verbose' : '--trace'
|
20
20
|
end
|
21
21
|
|
@@ -38,8 +38,14 @@ module CapistranoMulticonfigParallel
|
|
38
38
|
|
39
39
|
def read_config_file
|
40
40
|
return if CapistranoMulticonfigParallel.original_args.present? && CapistranoMulticonfigParallel.original_args.include?('--help')
|
41
|
-
|
42
|
-
config_file_path =
|
41
|
+
user = Etc.getlogin
|
42
|
+
config_file_path = File.join(Dir.home(user), "multi_cap.yml")
|
43
|
+
if File.exists?(config_file_path)
|
44
|
+
@fetched_config.config_dir = File.dirname(config_file_path)
|
45
|
+
else
|
46
|
+
@fetched_config.config_dir = @fetched_config.config_dir.present? ? File.expand_path(@fetched_config.config_dir) : try_detect_file('multi_cap.yml')
|
47
|
+
config_file_path = @fetched_config.config_dir.present? ? File.join(@fetched_config.config_dir, 'multi_cap.yml') : nil
|
48
|
+
end
|
43
49
|
config_file = File.expand_path(config_file_path || File.join(detect_root.to_s, 'config', 'multi_cap.yml'))
|
44
50
|
@fetched_config.log_dir = config_file_path.present? ? File.dirname(config_file) : File.dirname(File.dirname(config_file))
|
45
51
|
@fetched_config.read config_file if File.file?(config_file)
|
@@ -3,13 +3,29 @@ module CapistranoMulticonfigParallel
|
|
3
3
|
module InternalHelper
|
4
4
|
module_function
|
5
5
|
|
6
|
+
def get_current_gem_name
|
7
|
+
searcher = if Gem::Specification.respond_to? :find
|
8
|
+
# ruby 2.0
|
9
|
+
Gem::Specification
|
10
|
+
elsif Gem.respond_to? :searcher
|
11
|
+
# ruby 1.8/1.9
|
12
|
+
Gem.searcher.init_gemspecs
|
13
|
+
end
|
14
|
+
spec = unless searcher.nil?
|
15
|
+
searcher.find do |spec|
|
16
|
+
File.fnmatch(File.join(spec.full_gem_path,'*'), __FILE__)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
spec.name if spec.present?
|
20
|
+
end
|
21
|
+
|
6
22
|
def multi_level_prop(config, prop)
|
7
23
|
prop.split('.').each { |new_prop| config = config[new_prop] }
|
8
24
|
config
|
9
25
|
end
|
10
26
|
|
11
27
|
def internal_config_directory
|
12
|
-
|
28
|
+
File.join(root.to_s, get_current_gem_name, 'configuration')
|
13
29
|
end
|
14
30
|
|
15
31
|
def internal_config_file
|
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.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|