Class: CapistranoMulticonfigParallel::ChildProcessStatus

Inherits:
RunnerStatus
  • Object
show all
Defined in:
lib/capistrano_multiconfig_parallel/classes/child_process_status.rb

Overview

class that is used to execute the capistrano tasks and it is invoked by the celluloid worker

Constant Summary

Constants inherited from RunnerStatus

RunnerStatus::ATTRIBUTE_LIST

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RunnerStatus

#inspect, #log_to_worker, #on_pid, #to_json, #to_s

Methods included from ApplicationHelper

action_confirmed?, fetch_parsed_string, fetch_remaining_arguments, find_remaining_args, get_question_details, message_from_bundler?, message_is_about_a_task?, message_is_for_stdout?, msg_for_stdin?, parse_json, parse_task_string, percent_of, regex_last_match, setup_command_line_standard, truncate, wrap_string

Methods included from CapistranoHelper

env_key_format, env_prefix, filtered_env_keys_format, setup_flags_for_job, trace_flag

Methods included from GemHelper

fetch_gem_version, find_loaded_gem, find_loaded_gem_property, format_gem_version, get_parsed_version, verify_gem_version

Methods included from StagesHelper

app_names_from_stages, application_supports_multi_apps?, check_stage_path, checks_paths, configuration_has_valid_path?, fetch_apps_from_file, fetch_paths_from_file, fetch_stages_app, fetch_stages_paths, independent_deploy?, multi_apps?, sorted_paths, stages, stages_paths, stages_root

Methods included from ParseHelper

check_hash_set, check_numeric, strip_characters_from_string, value_is_array?, verify_array_of_strings, verify_empty_options, warn_array_without_strings

Methods included from CoreHelper

app_debug_enabled?, ask_confirm, ask_stdout_confirmation, check_terminal_tty, debug_websocket?, development_debug?, error_filtered?, execute_with_rescue, find_worker_log, force_confirmation, format_error, log_error, log_output_error, log_to_file, multi_fetch_argv, print_to_log_file, rescue_error, rescue_interrupt, setup_filename_logger, setup_logger_formatter, show_warning, terminal_actor, terminal_errors?, websocket_config, websocket_server_config

Methods included from InternalHelper

arg_is_in_default_config?, check_file, create_log_file, custom_commands, default_config_keys, default_internal_config, default_internal_configuration_params, detect_root, enable_main_log_file, fail_capfile_not_found, fetch_default_internal_config, find_config_type, find_env_multi_cap_root, find_file_by_names, find_file_in_directory, get_current_gem_name, internal_config_directory, internal_config_file, log_directory, main_log_file, multi_level_prop, pathname_is_root?, pwd_directory, pwd_parent_dir, root, setup_default_configuration_types, sliced_default_config, try_detect_file, try_detect_file_in_dir

Constructor Details

#initialize(process_runner, job, command, options = {}) ⇒ ChildProcessStatus

Returns a new instance of ChildProcessStatus.



8
9
10
11
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 8

def initialize(process_runner, job, command, options={})
  super(process_runner, job, command, options)
  @show_bundler = true
end

Instance Attribute Details

#show_bundlerObject

Returns the value of attribute show_bundler.



6
7
8
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 6

def show_bundler
  @show_bundler
end

Instance Method Details

#async_exception_handler(*data) ⇒ Object



55
56
57
58
59
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 55

def async_exception_handler(*data)
  log_to_file "Child process for worker #{@job_id} async_exception_handler  disconnected due to error #{data.inspect}"
  io_callback('stderr', data)
  @exit_status = 1
end

#io_callback(io, data) ⇒ Object



65
66
67
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 65

def io_callback(io, data)
  log_to_worker(data, io)
end

#on_exit(status) ⇒ Object



49
50
51
52
53
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 49

def on_exit(status)
  log_to_file "Child process for worker #{@job_id} on_exit  disconnected due to error #{exit_status.inspect}"
  print_error_if_exist
  @exit_status = status.exitstatus
end

#on_input_stdin(data) ⇒ Object



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

def on_input_stdin(data)
  io_callback('stdin', data)
end

#on_read_stderr(data) ⇒ Object



32
33
34
35
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 32

def on_read_stderr(data)
  @job.save_stderr_error(data) if development_debug?
  io_callback('stderr', data)
end

#on_read_stdout(data) ⇒ Object



26
27
28
29
30
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 26

def on_read_stdout(data)
  @show_bundler = false if  data.to_s.include?("The Gemfile's dependencies are satisfied") || data.to_s.include?("Bundle complete")
  @actor.async.update_machine_state(truncate(data, 40), :bundler => true) if @show_bundler == true && data.strip.present? && data.strip != '.'
  io_callback('stdout', data)
end

#on_size_limitObject



43
44
45
46
47
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 43

def on_size_limit
  log_to_file "Child process for worker #{@job_id} on_size_limit  disconnected"
  @did_size_limit = true
  @callback.call(self) if @expect_size_limit
end

#on_timeoutObject



37
38
39
40
41
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 37

def on_timeout
  log_to_file "Child process for worker #{@job_id} on_timeout  disconnected"
  @did_timeout = true
  @callback.call(self) if @expect_timeout
end


13
14
15
16
17
18
19
20
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 13

def print_error_if_exist
  return unless development_debug?
  [@job.stderr_buffer].each do |buffer|
    buffer.rewind
    data = buffer.read
    log_output_error(nil, 'stderr', "Child process for worker #{@job_id} died for reason: #{data}") if data.present?
  end
end

#watch_handler(process) ⇒ Object



61
62
63
# File 'lib/capistrano_multiconfig_parallel/classes/child_process_status.rb', line 61

def watch_handler(process)
  @process ||= process
end