capistrano_multiconfig_parallel 0.30.6 → 0.31.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0df399cd1c424694a1dd7c4176d54b021ce8c2b0
4
- data.tar.gz: c5b901a8017de673c10b3289ab609cdbc960f5c6
3
+ metadata.gz: d75fa1db22835b3a4dffbca4b1a77ea7d57b64a5
4
+ data.tar.gz: 711d8a286c0254a78d6cb99b2adc937df6aa1ac5
5
5
  SHA512:
6
- metadata.gz: f974b28eef0800c861e8e81894aa1992320dffb3e5d15b9e0cee2b210930d71e219fcc1903bb11a40729934da6d8bd671b21ddafbb4e9c3bf58e594475c83438
7
- data.tar.gz: c1a8f2b5d7b6291699965f87033e12d65c298880beae41fb665e6d81321697670f08e2be9211c0180c566f1fef03bce4b2946b097cd6111e3617e1018b3c89ee
6
+ metadata.gz: fda9e4e843d9d791dd00085ba53e1dbf5389cf3bbd635e5ca3a7ff4929b5f706f68cc67cbc38927578bab519b134bb94c512814938979216d56c62589287f9e0
7
+ data.tar.gz: dc2908a3203bf541c69eaa786f752a261b485067dc11aad375a8fe688ca6aa40404e1d43134831af12f0fbc2890dc7f642eb58202bb14a914c86779f6d7b1657
@@ -8,15 +8,13 @@ module CapistranoMulticonfigParallel
8
8
  include Capistrano::DSL
9
9
  include Capistrano::Multiconfig::DSL
10
10
 
11
- attr_reader :stage_apps, :top_level_tasks, :jobs, :branch_backup, :condition, :manager, :dependency_tracker, :application, :stage, :name, :args, :argv, :default_stage, :job_count
12
- attr_writer :job_count
11
+ attr_reader :stage_apps, :top_level_tasks, :jobs, :branch_backup, :condition, :manager, :dependency_tracker, :application, :stage, :name, :args, :argv, :default_stage
13
12
 
14
13
  def initialize
15
14
  Celluloid.boot
16
15
  CapistranoMulticonfigParallel.enable_logging
17
16
  @stage_apps = multi_apps? ? stages.map { |stage| stage.split(':').reverse[1] }.uniq : []
18
17
  collect_command_line_tasks(CapistranoMulticonfigParallel.original_args)
19
- @job_count = 0
20
18
  @jobs = []
21
19
  end
22
20
 
@@ -197,7 +195,7 @@ module CapistranoMulticonfigParallel
197
195
  def run_async_jobs
198
196
  return unless @jobs.present?
199
197
  @jobs.pmap do |job|
200
- @manager.async.delegate(job)
198
+ @manager.async.delegate_job(job)
201
199
  end
202
200
  unless can_tag_staging?
203
201
  until @manager.registration_complete
@@ -230,11 +228,10 @@ module CapistranoMulticonfigParallel
230
228
 
231
229
  env_options = branch_name.present? ? { 'BRANCH' => branch_name }.merge(options['env_options']) : options['env_options']
232
230
  job_env_options = custom_command? && env_options['ACTION'].present? ? env_options.except('ACTION') : env_options
233
- @job_count += 1
234
231
  job = CapistranoMulticonfigParallel::Job.new(Actor.current, options.merge(
235
232
  action: custom_command? && env_options['ACTION'].present? ? env_options['ACTION'] : options['action'],
236
- env_options: job_env_options,
237
- count: @job_count
233
+ env_options: job_env_options
234
+
238
235
  ))
239
236
  @jobs << job
240
237
  end
@@ -40,7 +40,7 @@ module CapistranoMulticonfigParallel
40
40
 
41
41
  # call to send an actor
42
42
  # a job
43
- def delegate(job)
43
+ def delegate_job(job)
44
44
  @jobs[job.id] = job
45
45
  # debug(@jobs)
46
46
  # start work and send it to the background
@@ -54,7 +54,7 @@ module CapistranoMulticonfigParallel
54
54
  @worker_to_job[worker.mailbox.address] = job
55
55
  log_to_file("worker #{worker.job_id} registed into manager")
56
56
  Actor.current.link worker
57
- worker.async.start_task if !syncronized_confirmation? || job.failed? || job.rolling_back?
57
+ worker.async.start_task if !syncronized_confirmation? || job.rolling_back?
58
58
  return unless syncronized_confirmation?
59
59
  @registration_complete = true if @job_manager.jobs.size == @jobs.size
60
60
  end
@@ -193,10 +193,9 @@ module CapistranoMulticonfigParallel
193
193
  return unless job.is_a?(CapistranoMulticonfigParallel::Job)
194
194
  options.stringify_keys! if options.present?
195
195
  env_opts = options['skip_env_options'].present? ? {} : @job_manager.get_app_additional_env_options(job.app, job.stage)
196
- @job_manager.job_count += 1
197
- new_job_options = job.options.merge('env_options' => job.env_options.merge(env_opts), 'count' => @job_manager.job_count)
196
+ new_job_options = job.options.except!('id', 'status', 'exit_status').merge('env_options' => job.env_options.merge(env_opts))
198
197
  new_job = CapistranoMulticonfigParallel::Job.new(@job_manager, new_job_options.merge(options))
199
- async.delegate(new_job) unless job.worker_died?
198
+ async.delegate_job(new_job) unless job.rolling_back?
200
199
  end
201
200
 
202
201
  # lookup status of job by asking actor running it
@@ -216,11 +215,11 @@ module CapistranoMulticonfigParallel
216
215
 
217
216
  def worker_died(worker, reason)
218
217
  job = @worker_to_job[worker.mailbox.address]
219
- return true if job.blank? || job.worker_died? || job.action != 'deploy'
218
+ return true if job.blank? || job.rolling_back? || job.action != 'deploy'
220
219
  mailbox = worker.mailbox
221
220
  @worker_to_job.delete(mailbox.address)
222
221
  log_to_file("RESTARTING: worker job #{job.inspect} with mailbox #{mailbox.inspect} and #{mailbox.address.inspect} died for reason: #{reason}")
223
- dispatch_new_job(job, skip_env_options: true, action: 'deploy:rollback', status: 'worker_died')
222
+ dispatch_new_job(job, skip_env_options: true, action: 'deploy:rollback')
224
223
  end
225
224
  end
226
225
  end
@@ -89,8 +89,9 @@ module CapistranoMulticonfigParallel
89
89
  def execute_deploy
90
90
  log_to_file("invocation chain #{@job_id} is : #{@rake_tasks.inspect}")
91
91
  check_child_proces
92
- log_to_file("worker #{@job_id} executes: #{@job.build_capistrano_task}")
93
- @child_process.async.work(@job, @job.build_capistrano_task, actor: Actor.current, silent: true)
92
+ command = job.command.to_s
93
+ log_to_file("worker #{@job_id} executes: #{command}")
94
+ @child_process.async.work(@job, command, actor: Actor.current, silent: true)
94
95
  end
95
96
 
96
97
  def check_child_proces
@@ -28,7 +28,7 @@ module CapistranoMulticonfigParallel
28
28
  end
29
29
 
30
30
  def default_heaadings
31
- ['Job ID', 'Job UUID', 'App/Stage', 'Action', 'ENV Variables', 'Current Task']
31
+ ['Job UUID', 'App/Stage', 'Action', 'ENV Variables', 'Current Status']
32
32
  end
33
33
 
34
34
  def run
@@ -35,7 +35,6 @@ module CapistranoMulticonfigParallel
35
35
 
36
36
  def terminal_row
37
37
  [
38
- { value: count.to_s },
39
38
  { value: id.to_s },
40
39
  { value: wrap_string(job_stage) },
41
40
  { value: wrap_string(capistrano_action) },
@@ -51,10 +50,13 @@ module CapistranoMulticonfigParallel
51
50
  (longest_hash[:value].size.to_f / 80.0).ceil
52
51
  end
53
52
 
53
+ def worker
54
+ return unless @manager.alive?
55
+ @manager.get_worker_for_job(id)
56
+ end
57
+
54
58
  def worker_state
55
59
  default = status.to_s.upcase.red
56
- return default unless @manager.alive?
57
- worker = @manager.get_worker_for_job(id)
58
60
  worker.alive? ? worker.worker_state : default
59
61
  end
60
62
 
@@ -69,8 +71,7 @@ module CapistranoMulticonfigParallel
69
71
  { name: 'task_arguments', default: [] },
70
72
  { name: 'env_options', default: {} },
71
73
  { name: 'status', default: :unstarted },
72
- { name: 'exit_status', default: nil },
73
- { name: 'count', default: nil }
74
+ { name: 'exit_status', default: nil }
74
75
  ].each do |hash|
75
76
  define_method hash[:name] do
76
77
  value = @options.fetch(hash[:name], hash[:default])
@@ -93,7 +94,7 @@ module CapistranoMulticonfigParallel
93
94
  end
94
95
 
95
96
  def crashed?
96
- failed? || dead? || worker_died? || exit_status.present?
97
+ worker_died? || failed? || dead? || exit_status.present?
97
98
  end
98
99
 
99
100
  def dead?
@@ -101,7 +102,15 @@ module CapistranoMulticonfigParallel
101
102
  end
102
103
 
103
104
  def worker_died?
104
- status.present? && status.to_s.downcase == 'worker_died'
105
+ !worker.alive?
106
+ end
107
+
108
+ def to_json
109
+ hash = {}
110
+ %w(id app stage action task_arguments env_options status exit_status).each do |key|
111
+ hash[key] = send(key)
112
+ end
113
+ hash
105
114
  end
106
115
  end
107
116
  end
@@ -21,9 +21,9 @@ module CapistranoMulticonfigParallel
21
21
  app.present? ? "#{app}:#{stage}" : "#{stage}"
22
22
  end
23
23
 
24
- def capistrano_action(rake_action = action)
24
+ def capistrano_action
25
25
  argv = task_arguments.present? ? "[#{task_arguments}]" : ''
26
- "#{rake_action}#{argv}"
26
+ "#{action}#{argv}"
27
27
  end
28
28
 
29
29
  def env_option_filtered?(key, filtered_keys_array = [])
@@ -44,10 +44,13 @@ module CapistranoMulticonfigParallel
44
44
  setup_env_options(options).concat(new_arguments)
45
45
  end
46
46
 
47
- def build_capistrano_task(rake_action = nil, *args)
48
- rake_action = rake_action.present? ? rake_action : action
49
- environment_options = setup_command_line(*args).join(' ')
50
- "cd #{detect_root} && RAILS_ENV=#{@stage} bundle exec multi_cap #{job_stage} #{capistrano_action(rake_action)} #{environment_options}"
47
+ def to_s
48
+ environment_options = setup_command_line.join(' ')
49
+ "cd #{detect_root} && RAILS_ENV=#{@stage} bundle exec multi_cap #{job_stage} #{capistrano_action} #{environment_options}"
50
+ end
51
+
52
+ def to_json
53
+ { command: to_s }
51
54
  end
52
55
 
53
56
  def execute_standard_deploy(action = nil)
@@ -92,7 +92,7 @@ module CapistranoMulticonfigParallel
92
92
  end
93
93
 
94
94
  def strip_characters_from_string(value)
95
- return unless value.present?
95
+ return '' if value.blank?
96
96
  value = value.delete("\r\n").delete("\n")
97
97
  value = value.gsub(/\s+/, ' ').strip
98
98
  value
@@ -7,8 +7,8 @@ module CapistranoMulticonfigParallel
7
7
  # module used for generating the version
8
8
  module VERSION
9
9
  MAJOR = 0
10
- MINOR = 30
11
- TINY = 6
10
+ MINOR = 31
11
+ TINY = 0
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
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: 0.30.6
4
+ version: 0.31.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-01-04 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid-pmap