Module: CapistranoMulticonfigParallel

Includes:
Configuration
Defined in:
lib/capistrano_multiconfig_parallel/base.rb,
lib/capistrano_multiconfig_parallel/cli.rb,
lib/capistrano_multiconfig_parallel/version.rb,
lib/capistrano_multiconfig_parallel/application.rb,
lib/capistrano_multiconfig_parallel/configuration.rb,
lib/capistrano_multiconfig_parallel/initializers/helper.rb,
lib/capistrano_multiconfig_parallel/helpers/base_manager.rb,
lib/capistrano_multiconfig_parallel/celluloid/rake_worker.rb,
lib/capistrano_multiconfig_parallel/celluloid/child_process.rb,
lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb,
lib/capistrano_multiconfig_parallel/helpers/standard_deploy.rb,
lib/capistrano_multiconfig_parallel/celluloid/terminal_table.rb,
lib/capistrano_multiconfig_parallel/helpers/multi_app_manager.rb,
lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb,
lib/capistrano_multiconfig_parallel/helpers/single_app_manager.rb,
lib/capistrano_multiconfig_parallel/celluloid/celluloid_manager.rb,
lib/capistrano_multiconfig_parallel/multi_app_helpers/interactive_menu.rb,
lib/capistrano_multiconfig_parallel/multi_app_helpers/dependency_tracker.rb

Overview

Returns the version of the currently loaded gem as a Gem::Version

Defined Under Namespace

Modules: Configuration, VERSION Classes: Application, BaseManager, CLI, CelluloidManager, CelluloidWorker, ChildProcess, DependencyTracker, Helper, InteractiveMenu, MultiAppManager, RakeWorker, SingleAppManager, StandardDeploy, StateMachine, TerminalTable

Constant Summary collapse

ENV_KEY_JOB_ID =
'multi_cap_job_id'
MULTI_KEY =
'multi'
SINGLE_KEY =
'single'
GITFLOW_TAG_STAGING_TASK =
"gitflow:tag_staging"
CUSTOM_COMMANDS =
{
  CapistranoMulticonfigParallel::MULTI_KEY => {
    stages: 'deploy_multi_stages'
  },
  CapistranoMulticonfigParallel::SINGLE_KEY => {
    stages: 'deploy_multi_stages'
  }
}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.execute_in_sequence ⇒ Object

Returns the value of attribute execute_in_sequence.



20
21
22
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 20

def execute_in_sequence
  @execute_in_sequence
end

.interactive_menu ⇒ Object

Returns the value of attribute interactive_menu.



20
21
22
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 20

def interactive_menu
  @interactive_menu
end

.logger ⇒ Object

Returns the value of attribute logger.



20
21
22
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 20

def logger
  @logger
end

.original_args ⇒ Object

Returns the value of attribute original_args.



20
21
22
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 20

def original_args
  @original_args
end

.show_task_progress ⇒ Object

Returns the value of attribute show_task_progress.



20
21
22
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 20

def show_task_progress
  @show_task_progress
end

Class Method Details

.ask_confirm(message, default) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 26

def ask_confirm(message, default)
  begin
  Ask.input message, default: default
  rescue
    return nil
  end
end

.detect_root ⇒ Object



78
79
80
81
82
83
84
85
86
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 78

def detect_root
  if ENV['MULTI_CAP_ROOT']
    Pathname.new(ENV['MULTI_CAP_ROOT'])
  elsif defined?(::Rails)
    ::Rails.root
  else
    try_detect_capfile
  end
end

.enable_logging ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 46

def enable_logging
  CapistranoMulticonfigParallel.configuration_valid?
  FileUtils.mkdir_p(log_directory) unless File.directory?(log_directory)
  if  CapistranoMulticonfigParallel::CelluloidManager.debug_enabled.to_s.downcase == 'true'
    FileUtils.touch(main_log_file) unless File.file?(main_log_file)
    if ENV[CapistranoMulticonfigParallel::ENV_KEY_JOB_ID].blank?
      log_file = File.open(main_log_file, 'w')
      log_file.sync = true
    end
    self.logger = ::Logger.new(main_log_file)
  else
    self.logger =  ::Logger.new(DevNull.new)
  end
  Celluloid.logger = CapistranoMulticonfigParallel.logger
  Celluloid.task_class = Celluloid::TaskThread
end

.gem_version ⇒ Object



3
4
5
# File 'lib/capistrano_multiconfig_parallel/version.rb', line 3

def self.gem_version
  Gem::Version.new VERSION::STRING
end

.log_directory ⇒ Object



34
35
36
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 34

def log_directory
  File.join(CapistranoMulticonfigParallel.detect_root.to_s, 'log')
end

.log_message(message) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 63

def log_message(message)
  return unless logger.present?
  error_message = message.respond_to?(:message) ? message.message : message.inspect
  err_backtrace = message.respond_to?(:backtrace) ? message.backtrace.join("\n\n") : ''
  if err_backtrace.present?
    logger.debug(
      class_name: message.class,
      message: error_message,
      backtrace: err_backtrace
    )
  else
    logger.debug(message)
  end
end

.main_log_file ⇒ Object



38
39
40
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 38

def main_log_file
  File.join(log_directory, 'multi_cap.log')
end

.root ⇒ Object



22
23
24
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 22

def root
  File.expand_path(File.dirname(__dir__))
end

.try_detect_capfile ⇒ Object



88
89
90
91
92
93
94
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 88

def try_detect_capfile
  root = Pathname.new(FileUtils.pwd)
  root = root.parent unless root.directory?
  root = root.parent until root.children.find { |f| f.file? && f.basename.to_s.downcase == 'capfile' }.present? || root.root?
  raise "Can't detect Rails application root" if root.root?
  root
end

.websokect_log_file ⇒ Object



42
43
44
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 42

def websokect_log_file
  File.join(log_directory, 'multi_cap_websocket.log')
end