Skip to content

Commit

Permalink
Merge branch 'release/0.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanRada committed Jun 30, 2015
2 parents 7d70ae4 + f582db3 commit 43edf5c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
24 changes: 16 additions & 8 deletions lib/capistrano_multiconfig_parallel/celluloid/celluloid_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,18 @@ def process_jobs(&block)
@job_manager.condition.signal(results2) if results2.size == @jobs.size
end

def need_confirmations?
CapistranoMulticonfigParallel.configuration.task_confirmation_active.to_s.downcase == 'true'
end

def wait_task_confirmations
return unless CapistranoMulticonfigParallel.configuration.task_confirmation_active
return unless need_confirmations?
CapistranoMulticonfigParallel.configuration.task_confirmations.each_with_index do |task, index|
results = []
@jobs.pmap do |job_id, _job|
results << @job_to_condition[job_id][:first_condition][index].wait
current_job = @job_to_condition[job_id][:first_condition][index]
result = current_job.respond_to?(:wait) ? current_job.wait : current_job
results << result
end
if results.size == @jobs.size
confirm_task_approval(results, task)
Expand All @@ -120,17 +126,19 @@ def wait_task_confirmations

def confirm_task_approval(results, task)
return unless results.present?
set :apps_symlink_confirmation, CapistranoMulticonfigParallel.ask_confirm("Do you want to continue the deployment and execute #{task}?", 'Y/N')
until fetch(:apps_symlink_confirmation).present?
sleep(0.1) # keep current thread alive
if results.detect {|x| !x.is_a?(Proc)}
set :apps_symlink_confirmation, CapistranoMulticonfigParallel.ask_confirm("Do you want to continue the deployment and execute #{task}?", 'Y/N')
until fetch(:apps_symlink_confirmation).present?
sleep(0.1) # keep current thread alive
end
end
return if fetch(:apps_symlink_confirmation).blank? || fetch(:apps_symlink_confirmation).downcase != 'y'
@jobs.pmap do |job_id, job|
worker = get_worker_for_job(job_id)
worker.publish_rake_event('approved' => 'yes',
'action' => 'invoke',
'job_id' => job['id'],
'task' => task
'action' => 'invoke',
'job_id' => job['id'],
'task' => task
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def process_job(job)
end

def need_confirmation_for_tasks?
executes_deploy? && CapistranoMulticonfigParallel.configuration.task_confirmation_active
executes_deploy? == true && @manager.need_confirmations?
end

def executes_deploy?
Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano_multiconfig_parallel/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.gem_version
module VERSION
MAJOR = 0
MINOR = 1
TINY = 3
TINY = 4
PRE = nil

STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
Expand Down

0 comments on commit 43edf5c

Please sign in to comment.