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/extensions/input_stream.rb,
lib/capistrano_multiconfig_parallel/helpers/standard_deploy.rb,
lib/capistrano_multiconfig_parallel/celluloid/terminal_table.rb,
lib/capistrano_multiconfig_parallel/extensions/output_stream.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/extensions/extension_helper.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, ExtensionHelper, Helper, InputStream, InteractiveMenu, MultiAppManager, OutputStream, 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'
GITFLOW_CALCULATE_TAG_TASK =
'gitflow:calculate_tag'
GITFLOW_VERIFY_UPTODATE_TASK =
'gitflow:verify_up_to_date'
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.



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

def execute_in_sequence
  @execute_in_sequence
end

.interactive_menu ⇒ Object

Returns the value of attribute interactive_menu.



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

def interactive_menu
  @interactive_menu
end

.logger ⇒ Object

Returns the value of attribute logger.



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

def logger
  @logger
end

.original_args ⇒ Object

Returns the value of attribute original_args.



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

def original_args
  @original_args
end

.show_task_progress ⇒ Object

Returns the value of attribute show_task_progress.



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

def show_task_progress
  @show_task_progress
end

Class Method Details

.ask_confirm(message, default) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 33

def ask_confirm(message, default)
  `stty -raw echo`
  check_terminal_tty
  result = Ask.input message, default: default
  $stdout.flush
  `stty -raw echo`
  return result
rescue
  return nil
end

.check_terminal_tty ⇒ Object



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

def check_terminal_tty
  $stdin.sync = true if $stdin.isatty
  $stdout.sync = true if $stdout.isatty
end

.detect_root ⇒ Object



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

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



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 56

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



44
45
46
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 44

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

.log_message(message) ⇒ Object



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

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



48
49
50
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 48

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

.root ⇒ Object



24
25
26
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 24

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

.try_detect_capfile ⇒ Object



98
99
100
101
102
103
104
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 98

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



52
53
54
# File 'lib/capistrano_multiconfig_parallel/base.rb', line 52

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