Class: CapistranoMulticonfigParallel::RunnerStatus
- Inherits:
-
Object
- Object
- CapistranoMulticonfigParallel::RunnerStatus
show all
- Includes:
- ApplicationHelper
- Defined in:
- lib/capistrano_multiconfig_parallel/classes/runner_status.rb
Constant Summary
collapse
- ATTRIBUTE_LIST =
[
:job,
:process_runner,
:command,
:options,
:actor,
:job_id,
:output_text,
:error_text,
:exit_status,
:did_timeout,
:callback,
:pid,
:force_yield,
:expect_timeout,
:expect_size_limit,
:async_exception,
:process
]
Instance Method Summary
collapse
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
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
app_names_from_stages, check_stage_path, checks_paths, fetch_stages_app, fetch_stages_from_file, fetch_stages_paths, independent_deploy?, multi_apps?, sorted_paths, stages, stages_paths, stages_root
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
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
Constructor Details
#initialize(process_runner, job, command, options = {}) ⇒ RunnerStatus
Returns a new instance of RunnerStatus.
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 29
def initialize(process_runner, job, command, options={})
options = options.is_a?(Hash) ? options : {}
@job = job
@process_runner = process_runner
@command = command
@options = {:repeats=>1, :force_yield=>nil, :timeout=>nil, :expect_timeout=>false}.merge(options)
@options = @options.symbolize_keys
@actor = @options.fetch(:actor, nil)
@job_id = @job.id
@process_runner = process_runner
@output_text = ""
@error_text = ""
@exit_status = nil
@did_timeout = false
@callback = @options[:callback].present? ? @options[:callback] : nil
@pid = nil
@force_yield = @options[:force_yield]
@expect_timeout = @options[:expect_timeout] || false
@expect_size_limit = @options[:expect_size_limit] || false
@async_exception = nil
end
|
Instance Method Details
#async_exception_handler(async_exception) ⇒ Object
105
106
107
108
109
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 105
def async_exception_handler(async_exception)
@async_exception = async_exception
log_to_worker "Child process for worker #{@job_id} async_exception_handler disconnected due to error #{data.inspect}"
@exit_status = 1
end
|
#inspect ⇒ Object
116
117
118
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 116
def inspect
to_s
end
|
#log_to_worker(message, io = nil) ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 55
def log_to_worker(message, io = nil)
if io.present?
log_to_file("#{io.upcase} ---- #{message}", job_id: @job_id, prefix: @options[:log_prefix])
elsif @options[:log_prefix].present?
log_to_file(message, job_id: @job_id, prefix: @options[:log_prefix])
else
log_to_file(message)
end
end
|
#on_exit(status) ⇒ Object
99
100
101
102
103
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 99
def on_exit(status)
log_to_worker "Child process for worker #{@job_id} on_exit disconnected due to #{status.inspect}"
@exit_status = status.exitstatus
@callback.call(self) if @callback && process_runner.synchronicity == :sync
end
|
71
72
73
74
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 71
def on_input_stdin(data)
log_to_worker(data, "stdin")
@output_text << data
end
|
#on_pid(pid) ⇒ Object
65
66
67
68
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 65
def on_pid(pid)
log_to_worker"Child process for worker #{@job_id} on_pid #{pid.inspect}"
@pid ||= pid
end
|
#on_read_stderr(data) ⇒ Object
81
82
83
84
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 81
def on_read_stderr(data)
log_to_worker(data, "stderr")
@error_text << data
end
|
#on_read_stdout(data) ⇒ Object
76
77
78
79
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 76
def on_read_stdout(data)
log_to_worker(data, "stdout")
@output_text << data
end
|
#on_size_limit ⇒ Object
93
94
95
96
97
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 93
def on_size_limit
log_to_worker "Child process for worker #{@job_id} on_size_limit disconnected"
@did_size_limit = true
@callback.call(self) if @callback && process_runner.synchronicity == :sync && @expect_size_limit
end
|
#on_timeout ⇒ Object
87
88
89
90
91
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 87
def on_timeout
log_to_worker "Child process for worker #{@job_id} on_timeout disconnected"
@did_timeout = true
@callback.call(self) if @callback && process_runner.synchronicity == :sync && @expect_timeout
end
|
#to_json ⇒ Object
124
125
126
127
128
129
130
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 124
def to_json
hash = {}
CapistranoMulticonfigParallel::RunnerStatus::ATTRIBUTE_LIST.delete_if{|a| [:process_runner].include?(a) }.each do |key|
hash[key] = send(key).inspect
end
hash
end
|
#to_s ⇒ Object
120
121
122
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 120
def to_s
JSON.generate(to_json)
end
|
#watch_handler(process) ⇒ Object
111
112
113
|
# File 'lib/capistrano_multiconfig_parallel/classes/runner_status.rb', line 111
def watch_handler(process)
@process ||= process
end
|