capistrano_multiconfig_parallel 0.8.0 → 0.8.1
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/celluloid/celluloid_manager.rb +23 -12
- data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb +7 -5
- data/lib/capistrano_multiconfig_parallel/celluloid/child_process.rb +8 -3
- data/lib/capistrano_multiconfig_parallel/celluloid/rake_worker.rb +5 -5
- data/lib/capistrano_multiconfig_parallel/celluloid/terminal_table.rb +4 -2
- data/lib/capistrano_multiconfig_parallel/helpers/base_manager.rb +1 -1
- data/lib/capistrano_multiconfig_parallel/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebf7abf008cd1254ba273dc97467920cbb2be773
|
4
|
+
data.tar.gz: 91ed0dd95fafd3fc453ade3d653c575ddab0a13e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3601c465aa36710d7c9b31f018bf314f18e87b2db73cf896ad8a19524f7123930fd79413dc66bc0316af35fe63902d3c08dcae30c868aae6bdde66dfbd7797a
|
7
|
+
data.tar.gz: 0c9ccaac1b56a1c344629993bbab0fa417e18c16178fb5c2c75bf7037c964138a6771c744b0a1b15f3c86e12d34a54e55fb351f66e7faa9f8ebf89c9bdb54e54
|
@@ -9,7 +9,7 @@ module CapistranoMulticonfigParallel
|
|
9
9
|
|
10
10
|
cattr_accessor :debug_enabled
|
11
11
|
|
12
|
-
attr_accessor :jobs, :job_to_worker, :worker_to_job, :actor_system, :job_to_condition, :mutex, :registration_complete
|
12
|
+
attr_accessor :jobs, :job_to_worker, :worker_to_job, :actor_system, :job_to_condition, :mutex, :registration_complete, :workers_terminated
|
13
13
|
|
14
14
|
attr_reader :worker_supervisor, :workers
|
15
15
|
trap_exit :worker_died
|
@@ -34,7 +34,7 @@ module CapistranoMulticonfigParallel
|
|
34
34
|
@worker_to_job = {}
|
35
35
|
@job_to_condition = {}
|
36
36
|
|
37
|
-
@worker_supervisor.supervise_as(:terminal_server, CapistranoMulticonfigParallel::TerminalTable, Actor.current)
|
37
|
+
@worker_supervisor.supervise_as(:terminal_server, CapistranoMulticonfigParallel::TerminalTable, Actor.current, @job_manager)
|
38
38
|
@worker_supervisor.supervise_as(:web_server, CelluloidPubsub::WebServer, self.class.websocket_config.merge(enable_debug: self.class.debug_websocket?))
|
39
39
|
end
|
40
40
|
|
@@ -93,19 +93,24 @@ module CapistranoMulticonfigParallel
|
|
93
93
|
@registration_complete = true if @job_manager.jobs.size == @job_to_worker.size
|
94
94
|
end
|
95
95
|
|
96
|
+
def all_workers_finished?
|
97
|
+
@job_to_worker.all? { |job_id, worker| @jobs[job_id]['worker_action'] == 'finished' }
|
98
|
+
end
|
99
|
+
|
96
100
|
def process_jobs
|
101
|
+
@workers_terminated = Celluloid::Condition.new
|
97
102
|
if syncronized_confirmation?
|
98
103
|
@job_to_worker.pmap do |_job_id, worker|
|
99
104
|
worker.async.start_task
|
100
105
|
end
|
101
106
|
wait_task_confirmations
|
102
107
|
end
|
103
|
-
condition = @
|
104
|
-
until condition
|
108
|
+
condition = @workers_terminated.wait
|
109
|
+
until condition.present?
|
105
110
|
sleep(0.1) # keep current thread alive
|
106
|
-
|
111
|
+
end
|
107
112
|
debug("all jobs have completed #{condition}") if self.class.debug_enabled?
|
108
|
-
|
113
|
+
Celluloid::Actor[:terminal_server].async.notify_time_change( CapistranoMulticonfigParallel::TerminalTable::TOPIC, :type => "output") if Celluloid::Actor[:terminal_server].alive?
|
109
114
|
end
|
110
115
|
|
111
116
|
def apply_confirmations?
|
@@ -191,10 +196,10 @@ module CapistranoMulticonfigParallel
|
|
191
196
|
@jobs.pmap do |job_id, job|
|
192
197
|
worker = get_worker_for_job(job_id)
|
193
198
|
worker.publish_rake_event('approved' => 'yes',
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
199
|
+
'action' => 'invoke',
|
200
|
+
'job_id' => job['id'],
|
201
|
+
'task' => task
|
202
|
+
)
|
198
203
|
end
|
199
204
|
end
|
200
205
|
|
@@ -228,6 +233,9 @@ module CapistranoMulticonfigParallel
|
|
228
233
|
end
|
229
234
|
|
230
235
|
def process_job(job)
|
236
|
+
if job['processed']
|
237
|
+
@jobs[job['job_id']]
|
238
|
+
else
|
231
239
|
env_options = {}
|
232
240
|
job['env_options'].each do |key, value|
|
233
241
|
env_options[key] = value if value.present? && !filtered_env_keys.include?(key)
|
@@ -238,8 +246,10 @@ module CapistranoMulticonfigParallel
|
|
238
246
|
'env_name' => job['env'],
|
239
247
|
'action_name' => job['action'],
|
240
248
|
'env_options' => env_options,
|
241
|
-
'task_arguments' => job['task_arguments']
|
242
|
-
|
249
|
+
'task_arguments' => job['task_arguments'],
|
250
|
+
'processed' => true
|
251
|
+
}
|
252
|
+
end
|
243
253
|
end
|
244
254
|
|
245
255
|
# lookup status of job by asking actor running it
|
@@ -265,6 +275,7 @@ module CapistranoMulticonfigParallel
|
|
265
275
|
def worker_died(worker, reason)
|
266
276
|
debug("worker with mailbox #{worker.mailbox.inspect} died for reason: #{reason}") if self.class.debug_enabled?
|
267
277
|
job = @worker_to_job[worker.mailbox.address]
|
278
|
+
return if @jobs[job['job_id']]['worker_action'] == "finished"
|
268
279
|
@worker_to_job.delete(worker.mailbox.address)
|
269
280
|
debug "restarting #{job} on new worker" if self.class.debug_enabled?
|
270
281
|
return if job.blank? || job_failed?(job)
|
@@ -26,7 +26,7 @@ module CapistranoMulticonfigParallel
|
|
26
26
|
:rake_tasks, :current_task_number, # tracking tasks
|
27
27
|
:successfull_subscription, :subscription_channel, :publisher_channel, # for subscriptions and publishing events
|
28
28
|
:job_termination_condition, :worker_state
|
29
|
-
|
29
|
+
|
30
30
|
def work(job, manager)
|
31
31
|
@job = job
|
32
32
|
@worker_state = 'started'
|
@@ -217,10 +217,12 @@ module CapistranoMulticonfigParallel
|
|
217
217
|
|
218
218
|
def finish_worker
|
219
219
|
@manager.mark_completed_remaining_tasks(Actor.current)
|
220
|
-
@
|
221
|
-
@manager.
|
222
|
-
|
223
|
-
|
220
|
+
@manager.jobs[@job_id]['worker_action'] = 'finished'
|
221
|
+
@manager.workers_terminated.signal('completed') if @manager.all_workers_finished?
|
222
|
+
end
|
223
|
+
|
224
|
+
def worker_finshed?
|
225
|
+
@manager.jobs[@job_id]['worker_action'] == 'finished'
|
224
226
|
end
|
225
227
|
|
226
228
|
def notify_finished(exit_status)
|
@@ -6,6 +6,8 @@ module CapistranoMulticonfigParallel
|
|
6
6
|
|
7
7
|
attr_accessor :actor, :pid, :exit_status, :process, :filename, :worker_log
|
8
8
|
|
9
|
+
finalizer :process_finalizer
|
10
|
+
|
9
11
|
def work(cmd, options = {})
|
10
12
|
@options = options
|
11
13
|
@actor = @options.fetch(:actor, nil)
|
@@ -37,14 +39,17 @@ module CapistranoMulticonfigParallel
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
|
-
def
|
41
|
-
return unless @exit_status.present?
|
42
|
+
def process_finalizer
|
42
43
|
@timer.cancel
|
43
44
|
EM.stop
|
45
|
+
end
|
46
|
+
|
47
|
+
def check_exit_status
|
48
|
+
return unless @exit_status.present?
|
44
49
|
if @options[:dry_run]
|
45
50
|
debug("worker #{@actor.job_id} starts execute deploy") if @actor.debug_enabled?
|
46
51
|
@actor.async.execute_deploy
|
47
|
-
|
52
|
+
elsif !@actor.worker_finshed?
|
48
53
|
debug("worker #{@actor.job_id} startsnotify finished") if @actor.debug_enabled?
|
49
54
|
@actor.notify_finished(@exit_status)
|
50
55
|
end
|
@@ -21,15 +21,15 @@ module CapistranoMulticonfigParallel
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def wait_execution(name = task_name, time = 0.1)
|
24
|
-
|
24
|
+
# info "Before waiting #{name}"
|
25
25
|
Actor.current.wait_for(name, time)
|
26
|
-
|
26
|
+
# info "After waiting #{name}"
|
27
27
|
end
|
28
28
|
|
29
29
|
def wait_for(name, time)
|
30
|
-
|
30
|
+
# info "waiting for #{time} seconds on #{name}"
|
31
31
|
sleep time
|
32
|
-
|
32
|
+
# info "done waiting on #{name} "
|
33
33
|
end
|
34
34
|
|
35
35
|
def default_settings
|
@@ -95,7 +95,7 @@ module CapistranoMulticonfigParallel
|
|
95
95
|
publish_to_worker(task_data)
|
96
96
|
@successfull_subscription = true
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
def stdin_approval(message)
|
100
100
|
if @job_id.to_i == message['job_id'].to_i && message['approved'] == 'yes'
|
101
101
|
@stdin_result = message
|
@@ -8,8 +8,9 @@ module CapistranoMulticonfigParallel
|
|
8
8
|
include Celluloid::Logger
|
9
9
|
TOPIC = 'sshkit_terminal'
|
10
10
|
|
11
|
-
def initialize(manager)
|
11
|
+
def initialize(manager, job_manager)
|
12
12
|
@manager = manager
|
13
|
+
@job_manager = job_manager
|
13
14
|
async.run
|
14
15
|
end
|
15
16
|
|
@@ -49,6 +50,7 @@ module CapistranoMulticonfigParallel
|
|
49
50
|
puts table
|
50
51
|
puts "\n"
|
51
52
|
sleep(1)
|
53
|
+
@job_manager.condition.signal('completed') if @manager.all_workers_finished?
|
52
54
|
end
|
53
55
|
|
54
56
|
def worker_state(worker)
|
@@ -80,7 +82,7 @@ module CapistranoMulticonfigParallel
|
|
80
82
|
job = @manager.jobs[job_id]
|
81
83
|
processed_job = @manager.process_job(job)
|
82
84
|
worker = @manager.get_worker_for_job(job_id)
|
83
|
-
|
85
|
+
|
84
86
|
{
|
85
87
|
'job_id' => job_id,
|
86
88
|
'app_name' => processed_job['app_name'],
|
@@ -174,7 +174,7 @@ module CapistranoMulticonfigParallel
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def wait_jobs_termination
|
177
|
-
return if
|
177
|
+
return if CapistranoMulticonfigParallel.execute_in_sequence
|
178
178
|
result = @condition.wait
|
179
179
|
return unless result.present?
|
180
180
|
@manager.terminate
|