capistrano_multiconfig_parallel 0.21.6 → 0.21.7
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/terminal_table.rb +33 -64
- data/lib/capistrano_multiconfig_parallel/classes/job.rb +21 -6
- data/lib/capistrano_multiconfig_parallel/helpers/application_helper.rb +4 -0
- 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: 7f87a7482ae60ee3c54f450c9e20d6f489a7d2a4
|
4
|
+
data.tar.gz: 7716965e21fe4d4faf52ad69aadbb9dfb0039597
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ac991a6da052876428b36d49dbe2e37007b01623b53427ac497bb1983c71e0dff89ef7bd8cc2ab7a07b477d5f126bf2953debe5094d12ff3ee12e1ff3357a03
|
7
|
+
data.tar.gz: 7a244b45ad63e01d0224490fa24ed153d0fcbdfe9cce6b4761f10ce6914c15e94d2e182eb75c84c051afb9f2237b157a60ae8945f2fac2538da356570fa85101
|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
require_relative '../helpers/application_helper'
|
2
3
|
module CapistranoMulticonfigParallel
|
3
4
|
# class used to display the progress of each worker on terminal screen using a table
|
@@ -14,6 +15,8 @@ module CapistranoMulticonfigParallel
|
|
14
15
|
@manager = manager
|
15
16
|
@job_manager = job_manager
|
16
17
|
async.run
|
18
|
+
rescue => ex
|
19
|
+
rescue_exception(ex)
|
17
20
|
end
|
18
21
|
|
19
22
|
def run
|
@@ -21,91 +24,57 @@ module CapistranoMulticonfigParallel
|
|
21
24
|
end
|
22
25
|
|
23
26
|
def notify_time_change(_topic, _message)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
table
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
show_terminal_screen(table)
|
35
|
-
rescue => ex
|
36
|
-
log_to_file("Terminal Table client disconnected due to error #{ex.inspect}")
|
27
|
+
table = Terminal::Table.new(title: 'Deployment Status Table', headings: ['Job ID', 'Job UUID', 'App/Stage', 'Action', 'ENV Variables', 'Current Task'])
|
28
|
+
jobs = @manager.alive? ? @manager.jobs : []
|
29
|
+
setup_table_jobs(table, jobs)
|
30
|
+
display_table_on_terminal(table)
|
31
|
+
end
|
32
|
+
|
33
|
+
def rescue_exception(ex)
|
34
|
+
log_to_file("Terminal Table client disconnected due to error #{ex.inspect}")
|
37
35
|
log_error(ex, 'stderr')
|
38
36
|
terminate
|
39
37
|
end
|
40
38
|
|
39
|
+
def display_table_on_terminal(table)
|
40
|
+
terminal_clear
|
41
|
+
puts "\n#{table}\n"
|
42
|
+
signal_complete
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup_table_jobs(table, jobs)
|
46
|
+
jobs.each_with_index do |(_job_id, job), count|
|
47
|
+
add_job_to_table(table, job, count)
|
48
|
+
table.add_separator
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
41
52
|
def show_confirmation(message, default)
|
42
53
|
exclusive do
|
43
54
|
ask_confirm(message, default)
|
44
55
|
end
|
45
56
|
end
|
46
57
|
|
47
|
-
def
|
48
|
-
return
|
49
|
-
|
50
|
-
# table.style = { width: 20 }
|
51
|
-
puts "\n#{table}\n"
|
52
|
-
sleep(1)
|
53
|
-
if @job_manager.alive? && @manager.alive? && @manager.all_workers_finished?
|
54
|
-
@job_manager.condition.signal('completed')
|
55
|
-
end
|
58
|
+
def signal_complete
|
59
|
+
return if !@job_manager.alive? || @manager.alive?
|
60
|
+
@job_manager.condition.signal('completed') if @manager.all_workers_finished?
|
56
61
|
end
|
57
62
|
|
58
|
-
def worker_state(
|
63
|
+
def worker_state(job)
|
59
64
|
default = job.status.to_s.upcase.red
|
60
65
|
return default unless @manager.alive?
|
61
|
-
worker = @manager.get_worker_for_job(
|
66
|
+
worker = @manager.get_worker_for_job(job.id)
|
62
67
|
worker.alive? ? worker.worker_state : default
|
63
68
|
end
|
64
69
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
def add_job_to_table(table, job_id, job, index)
|
70
|
-
row = [{ value: (index + 1).to_s },
|
71
|
-
{ value: job_id.to_s },
|
72
|
-
{ value: job.job_stage },
|
73
|
-
{ value: job.capistrano_action },
|
74
|
-
{ value: job.setup_command_line_standard(filtered_keys: [CapistranoMulticonfigParallel::ENV_KEY_JOB_ID]).join("\n") },
|
75
|
-
{ value: worker_state(job_id, job) }
|
76
|
-
]
|
77
|
-
|
78
|
-
# if worker.alive?
|
79
|
-
# row << { value: job.rake_tasks.size }
|
80
|
-
# row << { value: worker_progress(job_id, job) }
|
81
|
-
# else
|
82
|
-
# row << { value: 0 }
|
83
|
-
# row << { value: worker_state(job_id) }
|
84
|
-
# end
|
85
|
-
table.add_row(row)
|
86
|
-
table.add_separator
|
87
|
-
table
|
70
|
+
def add_job_to_table(table, job, index)
|
71
|
+
job_state = worker_state(job)
|
72
|
+
job_row = job.terminal_row(index, job_state)
|
73
|
+
table.add_row(job_row)
|
88
74
|
end
|
89
75
|
|
90
76
|
def terminal_clear
|
91
77
|
system('cls') || system('clear') || puts("\e[H\e[2J")
|
92
78
|
end
|
93
|
-
|
94
|
-
# def worker_progress(job)
|
95
|
-
# tasks = job.rake_tasks.size
|
96
|
-
# current_task = job.status
|
97
|
-
# show_worker_percent(tasks, current_task, job)
|
98
|
-
# end
|
99
|
-
#
|
100
|
-
# def show_worker_percent(tasks, current_task, job)
|
101
|
-
# task_index = tasks.index(current_task.to_s).to_i + 1
|
102
|
-
# percent = percent_of(task_index, total_tasks)
|
103
|
-
# result = "Progress [#{format('%.2f', percent)}%] (executed #{task_index} of #{total_tasks})"
|
104
|
-
# job.crashed? ? result.red : result.green
|
105
|
-
# end
|
106
|
-
#
|
107
|
-
# def percent_of(index, total)
|
108
|
-
# index.to_f / total.to_f * 100.0
|
109
|
-
# end
|
110
79
|
end
|
111
80
|
end
|
@@ -9,20 +9,35 @@ module CapistranoMulticonfigParallel
|
|
9
9
|
attr_writer :status, :exit_status
|
10
10
|
|
11
11
|
delegate :job_stage,
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
:capistrano_action,
|
13
|
+
:build_capistrano_task,
|
14
|
+
:execute_standard_deploy,
|
15
|
+
:setup_command_line_standard,
|
16
|
+
to: :command
|
17
17
|
|
18
18
|
def initialize(options)
|
19
19
|
@options = options
|
20
20
|
end
|
21
21
|
|
22
|
+
def env_variable
|
23
|
+
CapistranoMulticonfigParallel::ENV_KEY_JOB_ID
|
24
|
+
end
|
25
|
+
|
22
26
|
def command
|
23
27
|
@command ||= CapistranoMulticonfigParallel::JobCommand.new(self)
|
24
28
|
end
|
25
29
|
|
30
|
+
def terminal_row(index, job_state)
|
31
|
+
[
|
32
|
+
{ value: (index + 1).to_s },
|
33
|
+
{ value: id.to_s },
|
34
|
+
{ value: job_stage },
|
35
|
+
{ value: capistrano_action },
|
36
|
+
{ value: setup_command_line_standard(filtered_keys: [CapistranoMulticonfigParallel::ENV_KEY_JOB_ID]).join("\n") },
|
37
|
+
{ value: job_state }
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
26
41
|
def job_writer_attributes
|
27
42
|
%w(status exit_status)
|
28
43
|
end
|
@@ -54,7 +69,7 @@ module CapistranoMulticonfigParallel
|
|
54
69
|
].each do |hash|
|
55
70
|
define_method hash[:name] do
|
56
71
|
value = @options.fetch(hash[:name], hash[:default])
|
57
|
-
value["#{
|
72
|
+
value["#{env_variable}"] = id if hash[:name] == 'env_options'
|
58
73
|
verify_empty_options(value)
|
59
74
|
end
|
60
75
|
# define_method "#{hash[:name]}=" do |value|
|