capistrano_multiconfig_parallel 0.13.2 → 0.14.0
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/lib/capistrano_multiconfig_parallel/application.rb +1 -4
- data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_manager.rb +6 -7
- data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb +3 -2
- data/lib/capistrano_multiconfig_parallel/managers/base_manager.rb +35 -10
- data/lib/capistrano_multiconfig_parallel/managers/standard_deploy.rb +2 -2
- data/lib/capistrano_multiconfig_parallel/multi_app_helpers/dependency_tracker.rb +3 -2
- data/lib/capistrano_multiconfig_parallel/version.rb +2 -2
- metadata +1 -3
- data/lib/capistrano_multiconfig_parallel/managers/multi_app_manager.rb +0 -53
- data/lib/capistrano_multiconfig_parallel/managers/single_app_manager.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af426cfa70110d128cbe87845419726e79c208a1
|
4
|
+
data.tar.gz: 8fc920d2c30a6dba86a4454072f8545178b5e0cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7d415e6280a296e2245caa1d969ee18e7875a31c52fb7a7dccf2c299647cc3a7dc3378ca2bacd9a3fc28ef52086004bae92b0d9a336b9e9aa5fba790860f0c9
|
7
|
+
data.tar.gz: 8c6d73cd137cc0b2ab546ffd2d76aa9a26ff866d90a0a7d746ed38ffd237d78ca574074885cb9f4983030656c0c661acea359a645c19112df5e0b1f8cc482e05
|
@@ -10,7 +10,7 @@ module CapistranoMulticonfigParallel
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def top_level
|
13
|
-
job_manager =
|
13
|
+
job_manager = CapistranoMulticonfigParallel::BaseManager.new(self, top_level_tasks, stages)
|
14
14
|
if job_manager.can_start? && !options.show_prereqs && !options.show_tasks
|
15
15
|
job_manager.start
|
16
16
|
else
|
@@ -22,8 +22,5 @@ module CapistranoMulticonfigParallel
|
|
22
22
|
stages.find { |stage| stage.include?(':') }.present?
|
23
23
|
end
|
24
24
|
|
25
|
-
def multi_manager_class
|
26
|
-
multi_apps? ? CapistranoMulticonfigParallel::MultiAppManager : CapistranoMulticonfigParallel::SingleAppManager
|
27
|
-
end
|
28
25
|
end
|
29
26
|
end
|
@@ -121,16 +121,15 @@ module CapistranoMulticonfigParallel
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def syncronized_confirmation?
|
124
|
-
|
125
|
-
(@job_manager.executes_deploy_stages? && !@job_manager.can_tag_staging? && @job_manager.confirmation_applies_to_all_workers?)
|
124
|
+
!@job_manager.can_tag_staging?
|
126
125
|
end
|
127
126
|
|
128
127
|
def apply_confirmation_for_worker(worker)
|
129
|
-
worker.alive? && CapistranoMulticonfigParallel.configuration.apply_stage_confirmation.include?(worker.env_name)
|
128
|
+
worker.alive? && CapistranoMulticonfigParallel.configuration.apply_stage_confirmation.include?(worker.env_name) && apply_confirmations?
|
130
129
|
end
|
131
130
|
|
132
131
|
def setup_worker_conditions(worker)
|
133
|
-
return if !apply_confirmation_for_worker(worker)
|
132
|
+
return if !apply_confirmation_for_worker(worker)
|
134
133
|
hash_conditions = {}
|
135
134
|
CapistranoMulticonfigParallel.configuration.task_confirmations.each do |task|
|
136
135
|
hash_conditions[task] = { condition: Celluloid::Condition.new, status: 'unconfirmed' }
|
@@ -139,7 +138,7 @@ module CapistranoMulticonfigParallel
|
|
139
138
|
end
|
140
139
|
|
141
140
|
def mark_completed_remaining_tasks(worker)
|
142
|
-
return if !apply_confirmation_for_worker(worker)
|
141
|
+
return if !apply_confirmation_for_worker(worker)
|
143
142
|
CapistranoMulticonfigParallel.configuration.task_confirmations.each_with_index do |task, _index|
|
144
143
|
fake_result = proc { |sum| sum }
|
145
144
|
task_confirmation = @job_to_condition[worker.job_id][task]
|
@@ -151,7 +150,7 @@ module CapistranoMulticonfigParallel
|
|
151
150
|
end
|
152
151
|
|
153
152
|
def wait_task_confirmations_worker(worker)
|
154
|
-
return if
|
153
|
+
return if !apply_confirmation_for_worker(worker) || !syncronized_confirmation?
|
155
154
|
CapistranoMulticonfigParallel.configuration.task_confirmations.each_with_index do |task, _index|
|
156
155
|
result = wait_condition_for_task(worker.job_id, task)
|
157
156
|
confirm_task_approval(result, task, worker) if result.present?
|
@@ -164,7 +163,7 @@ module CapistranoMulticonfigParallel
|
|
164
163
|
|
165
164
|
def wait_task_confirmations
|
166
165
|
stage_apply = CapistranoMulticonfigParallel.configuration.apply_stage_confirmation.include?(@job_manager.stage)
|
167
|
-
return if !
|
166
|
+
return if !stage_apply || !syncronized_confirmation?
|
168
167
|
CapistranoMulticonfigParallel.configuration.task_confirmations.each_with_index do |task, _index|
|
169
168
|
results = []
|
170
169
|
@jobs.pmap do |job_id, _job|
|
@@ -149,8 +149,9 @@ module CapistranoMulticonfigParallel
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def task_approval(message)
|
152
|
-
|
153
|
-
|
152
|
+
job_conditions = @manager.job_to_condition[@job_id]
|
153
|
+
if job_conditions.present? && CapistranoMulticonfigParallel.configuration.task_confirmations.include?(message['task']) && message['action'] == 'invoke'
|
154
|
+
task_confirmation = job_conditions[message['task']]
|
154
155
|
task_confirmation[:status] = 'confirmed'
|
155
156
|
task_confirmation[:condition].signal(message['task'])
|
156
157
|
else
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative './standard_deploy'
|
2
2
|
require_relative '../celluloid/celluloid_manager'
|
3
|
+
require_relative '../multi_app_helpers/dependency_tracker'
|
3
4
|
module CapistranoMulticonfigParallel
|
4
5
|
# finds app dependencies, shows menu and delegates jobs to celluloid manager
|
5
6
|
# rubocop:disable ClassLength
|
@@ -19,14 +20,38 @@ module CapistranoMulticonfigParallel
|
|
19
20
|
def run
|
20
21
|
options = {}
|
21
22
|
if custom_command?
|
23
|
+
options = verify_options_custom_command(options)
|
22
24
|
run_custom_command(options)
|
23
25
|
else
|
24
|
-
|
25
|
-
run_normal_command(options)
|
26
|
+
collect_jobs(options)
|
26
27
|
end
|
27
28
|
process_jobs
|
28
29
|
end
|
29
30
|
|
31
|
+
|
32
|
+
def run_custom_command(options)
|
33
|
+
stages = fetch_multi_stages
|
34
|
+
return if stages.blank?
|
35
|
+
stages = check_multi_stages(stages)
|
36
|
+
stages.each do |stage|
|
37
|
+
collect_jobs(options.merge('stage' => stage))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def deploy_multiple_apps(applications, options)
|
42
|
+
options = options.stringify_keys
|
43
|
+
return unless applications.present?
|
44
|
+
applications.each do |app|
|
45
|
+
deploy_app(options.merge('app' => app))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def backup_the_branch
|
51
|
+
return if custom_command? || @argv['BRANCH'].blank?
|
52
|
+
@branch_backup = @argv['BRANCH'].to_s
|
53
|
+
@argv['BRANCH'] = nil
|
54
|
+
end
|
30
55
|
def can_start?
|
31
56
|
@top_level_tasks.size > 1 && (stages.include?(@top_level_tasks.first) || custom_command?) && ENV[CapistranoMulticonfigParallel::ENV_KEY_JOB_ID].blank?
|
32
57
|
end
|
@@ -108,7 +133,10 @@ module CapistranoMulticonfigParallel
|
|
108
133
|
def collect_jobs(options = {}, &block)
|
109
134
|
options = prepare_options(options)
|
110
135
|
options = options.stringify_keys
|
111
|
-
|
136
|
+
apps = @dependency_tracker.fetch_apps_needed_for_deployment(options['app'], options['action'])
|
137
|
+
backup_the_branch if multi_apps?
|
138
|
+
deploy_multiple_apps(apps, options)
|
139
|
+
deploy_app(options)
|
112
140
|
rescue => e
|
113
141
|
raise [e, e.backtrace].inspect
|
114
142
|
end
|
@@ -124,9 +152,9 @@ module CapistranoMulticonfigParallel
|
|
124
152
|
|
125
153
|
def tag_staging_exists? # check exists task from capistrano-gitflow
|
126
154
|
check_giflow_tasks(
|
127
|
-
|
128
|
-
|
129
|
-
|
155
|
+
CapistranoMulticonfigParallel::GITFLOW_TAG_STAGING_TASK,
|
156
|
+
CapistranoMulticonfigParallel::GITFLOW_CALCULATE_TAG_TASK,
|
157
|
+
CapistranoMulticonfigParallel::GITFLOW_VERIFY_UPTODATE_TASK
|
130
158
|
)
|
131
159
|
rescue
|
132
160
|
return false
|
@@ -178,11 +206,8 @@ module CapistranoMulticonfigParallel
|
|
178
206
|
@jobs.map { |job| job['env'] }
|
179
207
|
end
|
180
208
|
|
181
|
-
def confirmation_applies_to_all_workers?
|
182
|
-
CapistranoMulticonfigParallel.configuration.apply_stage_confirmation.all? { |e| worker_environments.include?(e) }
|
183
|
-
end
|
184
209
|
|
185
|
-
|
210
|
+
private
|
186
211
|
|
187
212
|
def call_task_deploy_app(options = {})
|
188
213
|
options = options.stringify_keys
|
@@ -7,8 +7,8 @@ module CapistranoMulticonfigParallel
|
|
7
7
|
attr_accessor :app, :stage, :action, :task_arguments, :env_options
|
8
8
|
def initialize(options)
|
9
9
|
@app = options.fetch('app', '')
|
10
|
-
@stage = options.fetch('env', '
|
11
|
-
@action = options.fetch('action', '
|
10
|
+
@stage = options.fetch('env', '')
|
11
|
+
@action = options.fetch('action', '')
|
12
12
|
@task_arguments = options.fetch('task_arguments:', [])
|
13
13
|
@env_options = options.fetch('env_options', {})
|
14
14
|
execute_standard_deploy
|
@@ -11,7 +11,8 @@ module CapistranoMulticonfigParallel
|
|
11
11
|
|
12
12
|
def fetch_apps_needed_for_deployment(application, action)
|
13
13
|
applications = []
|
14
|
-
|
14
|
+
return applications unless @job_manager.multi_apps?
|
15
|
+
if @job_manager.custom_command?
|
15
16
|
apps_selected = all_websites_return_applications_selected
|
16
17
|
applications = get_applications_to_deploy(action, apps_selected)
|
17
18
|
elsif CapistranoMulticonfigParallel.configuration.application_dependencies.present?
|
@@ -27,7 +28,7 @@ module CapistranoMulticonfigParallel
|
|
27
28
|
applications
|
28
29
|
end
|
29
30
|
|
30
|
-
|
31
|
+
private
|
31
32
|
|
32
33
|
def application_dependencies
|
33
34
|
deps = CapistranoMulticonfigParallel.configuration.application_dependencies
|
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: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
@@ -634,8 +634,6 @@ files:
|
|
634
634
|
- lib/capistrano_multiconfig_parallel/initializers/conf.rb
|
635
635
|
- lib/capistrano_multiconfig_parallel/initializers/default.yml
|
636
636
|
- lib/capistrano_multiconfig_parallel/managers/base_manager.rb
|
637
|
-
- lib/capistrano_multiconfig_parallel/managers/multi_app_manager.rb
|
638
|
-
- lib/capistrano_multiconfig_parallel/managers/single_app_manager.rb
|
639
637
|
- lib/capistrano_multiconfig_parallel/managers/standard_deploy.rb
|
640
638
|
- lib/capistrano_multiconfig_parallel/multi_app_helpers/dependency_tracker.rb
|
641
639
|
- lib/capistrano_multiconfig_parallel/multi_app_helpers/interactive_menu.rb
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require_relative './base_manager'
|
2
|
-
require_relative '../multi_app_helpers/dependency_tracker'
|
3
|
-
module CapistranoMulticonfigParallel
|
4
|
-
# class used to find application dependencies
|
5
|
-
class MultiAppManager < CapistranoMulticonfigParallel::BaseManager
|
6
|
-
include Celluloid
|
7
|
-
include Celluloid::Logger
|
8
|
-
|
9
|
-
def run_normal_command(options)
|
10
|
-
multi_collect_and_run_jobs(options) do |apps, new_options|
|
11
|
-
deploy_multiple_apps(apps, new_options)
|
12
|
-
deploy_app(new_options) if !custom_command? && new_options['app'].present?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def run_custom_command(options)
|
17
|
-
stages = fetch_multi_stages
|
18
|
-
return if stages.blank?
|
19
|
-
stages = check_multi_stages(stages)
|
20
|
-
multi_collect_and_run_jobs(options) do |apps, new_options|
|
21
|
-
apps.each do |app|
|
22
|
-
stages.each do |stage|
|
23
|
-
deploy_app(new_options.merge('app' => app, 'stage' => stage))
|
24
|
-
end
|
25
|
-
end if apps.present?
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def multi_collect_and_run_jobs(options = {}, &block)
|
32
|
-
collect_jobs(options) do |new_options|
|
33
|
-
applications = @dependency_tracker.fetch_apps_needed_for_deployment(new_options['app'], new_options['action'])
|
34
|
-
backup_the_branch
|
35
|
-
block.call(applications, new_options) if block_given?
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def backup_the_branch
|
40
|
-
return if custom_command? || @argv['BRANCH'].blank?
|
41
|
-
@branch_backup = @argv['BRANCH'].to_s
|
42
|
-
@argv['BRANCH'] = nil
|
43
|
-
end
|
44
|
-
|
45
|
-
def deploy_multiple_apps(applications, options)
|
46
|
-
options = options.stringify_keys
|
47
|
-
return unless applications.present?
|
48
|
-
applications.each do |app|
|
49
|
-
deploy_app(options.merge('app' => app))
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require_relative './base_manager'
|
2
|
-
module CapistranoMulticonfigParallel
|
3
|
-
# class used to find application dependencies
|
4
|
-
class SingleAppManager < CapistranoMulticonfigParallel::BaseManager
|
5
|
-
include Celluloid
|
6
|
-
include Celluloid::Logger
|
7
|
-
|
8
|
-
def run_normal_command(options)
|
9
|
-
collect_jobs(options) do |new_options|
|
10
|
-
deploy_app(new_options)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def run_custom_command(options)
|
15
|
-
stages = fetch_multi_stages
|
16
|
-
return if stages.blank?
|
17
|
-
stages = check_multi_stages(stages)
|
18
|
-
collect_jobs(options) do |new_options|
|
19
|
-
stages.each do |stage|
|
20
|
-
deploy_app(new_options.merge('stage' => stage))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|