Class: CapistranoMulticonfigParallel::MultiAppManager

Inherits:
BaseManager
  • Object
show all
Includes:
Celluloid, Celluloid::Logger
Defined in:
lib/capistrano_multiconfig_parallel/helpers/multi_app_manager.rb

Overview

class used to find application dependencies

Instance Attribute Summary

Attributes inherited from BaseManager

#application, #args, #argv, #condition, #default_stage, #deps, #job_registered_condition, #jobs, #manager, #name, #stage

Instance Method Summary collapse

Methods inherited from BaseManager

#can_start?, #collect_jobs, #custom_command?, #custom_commands, #deploy_app, #fetch_multi_stages, #multi_apps?, #process_jobs, #start

Constructor Details

#initialize(cap_app, top_level_tasks, stages) ⇒ MultiAppManager

Returns a new instance of MultiAppManager.



9
10
11
12
# File 'lib/capistrano_multiconfig_parallel/helpers/multi_app_manager.rb', line 9

def initialize(cap_app, top_level_tasks, stages)
  super(cap_app, top_level_tasks, stages)
  @dependency_tracker = CapistranoMulticonfigParallel::DependencyTracker.new(Actor.current)
end

Instance Method Details



50
51
52
53
54
55
# File 'lib/capistrano_multiconfig_parallel/helpers/multi_app_manager.rb', line 50

def menu_deploy_interactive(options)
  multi_collect_and_run_jobs(options) do |apps, new_options|
    deploy_multiple_apps(apps, new_options)
    deploy_app(new_options) if !custom_command? && new_options['app'].present?
  end
end

#multi_stage_deploy(options) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/capistrano_multiconfig_parallel/helpers/multi_app_manager.rb', line 38

def multi_stage_deploy(options)
  stages = fetch_multi_stages
  return if stages.blank?
  multi_collect_and_run_jobs(options) do |apps, new_options|
    apps.each do |app|
      stages.each do |stage|
        deploy_app(new_options.merge('app' => app, 'stage' => stage))
      end
    end if apps.present?
  end
end

#runObject



14
15
16
17
18
19
20
21
22
# File 'lib/capistrano_multiconfig_parallel/helpers/multi_app_manager.rb', line 14

def run
  options = {}
  if custom_command?
    run_custom_command(options)
  else
    menu_deploy_interactive(options)
  end
  process_jobs
end

#run_custom_command(options) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/capistrano_multiconfig_parallel/helpers/multi_app_manager.rb', line 24

def run_custom_command(options)
  return unless custom_command?
  CapistranoMulticonfigParallel.interactive_menu = true
  options[:action] = @argv['ACTION'].present? ? @argv['ACTION'].present? : 'deploy'
  action_name = @name
  if action_name == custom_commands[:menu]
    menu_deploy_interactive(options)
  elsif action_name == custom_commands[:stages]
    multi_stage_deploy(options)
  else
    raise "Custom command #{@name} not available for multi apps"
  end
end