Class: Aruba::Processes::BasicProcess
- Inherits:
-
Object
- Object
- Aruba::Processes::BasicProcess
- Defined in:
- lib/aruba/processes/basic_process.rb
Overview
Basic Process
‘BasicProcess` is not meant for direct use - `BasicProcess.new` - by users.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#exit_status ⇒ Object
readonly
Returns the value of attribute exit_status.
-
#exit_timeout ⇒ Object
readonly
Returns the value of attribute exit_timeout.
-
#io_wait_timeout ⇒ Object
readonly
Returns the value of attribute io_wait_timeout.
-
#main_class ⇒ Object
readonly
Returns the value of attribute main_class.
-
#startup_wait_time ⇒ Object
readonly
Returns the value of attribute startup_wait_time.
-
#stop_signal ⇒ Object
readonly
Returns the value of attribute stop_signal.
-
#working_directory ⇒ Object
readonly
Returns the value of attribute working_directory.
Instance Method Summary collapse
-
#after_run ⇒ Object
Hook which is run after command is run.
- #arguments ⇒ Object
-
#before_run ⇒ Object
Hook which is run before command is run.
- #close_io ⇒ Object
- #command ⇒ Object
-
#commandline ⇒ Object
Return command line.
- #content ⇒ Object
- #empty? ⇒ Boolean
- #filesystem_status ⇒ Object
-
#initialize(cmd, exit_timeout, io_wait_timeout, working_directory, environment = Aruba.platform.environment_variables.hash_from_env, main_class = nil, stop_signal = nil, startup_wait_time = 0) ⇒ BasicProcess
constructor
rubocop:disable Metrics/ParameterLists.
- #inspect ⇒ Object (also: #to_s)
-
#output(opts = {}) ⇒ Object
Output stderr and stdout.
-
#pid ⇒ Object
Output pid of process.
-
#restart ⇒ Object
Restart a command.
- #send_signal ⇒ Object
-
#started? ⇒ Boolean
Was process already started.
- #stderr ⇒ Object
- #stdin ⇒ Object
- #stdout ⇒ Object
-
#stopped? ⇒ Boolean
Was process already stopped.
-
#timed_out? ⇒ Boolean
Does the process failed to stop in time.
- #wait ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(cmd, exit_timeout, io_wait_timeout, working_directory, environment = Aruba.platform.environment_variables.hash_from_env, main_class = nil, stop_signal = nil, startup_wait_time = 0) ⇒ BasicProcess
rubocop:disable Metrics/ParameterLists
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/aruba/processes/basic_process.rb', line 19 def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, # rubocop:disable Metrics/ParameterLists environment = Aruba.platform.environment_variables.hash_from_env, main_class = nil, stop_signal = nil, startup_wait_time = 0) @cmd = cmd @working_directory = working_directory @environment = environment @main_class = main_class @exit_status = nil @stop_signal = stop_signal @startup_wait_time = startup_wait_time @exit_timeout = exit_timeout @io_wait_timeout = io_wait_timeout @started = false @timed_out = false end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
16 17 18 |
# File 'lib/aruba/processes/basic_process.rb', line 16 def environment @environment end |
#exit_status ⇒ Object (readonly)
Returns the value of attribute exit_status.
16 17 18 |
# File 'lib/aruba/processes/basic_process.rb', line 16 def exit_status @exit_status end |
#exit_timeout ⇒ Object (readonly)
Returns the value of attribute exit_timeout.
16 17 18 |
# File 'lib/aruba/processes/basic_process.rb', line 16 def exit_timeout @exit_timeout end |
#io_wait_timeout ⇒ Object (readonly)
Returns the value of attribute io_wait_timeout.
16 17 18 |
# File 'lib/aruba/processes/basic_process.rb', line 16 def io_wait_timeout @io_wait_timeout end |
#main_class ⇒ Object (readonly)
Returns the value of attribute main_class.
16 17 18 |
# File 'lib/aruba/processes/basic_process.rb', line 16 def main_class @main_class end |
#startup_wait_time ⇒ Object (readonly)
Returns the value of attribute startup_wait_time.
16 17 18 |
# File 'lib/aruba/processes/basic_process.rb', line 16 def startup_wait_time @startup_wait_time end |
#stop_signal ⇒ Object (readonly)
Returns the value of attribute stop_signal.
16 17 18 |
# File 'lib/aruba/processes/basic_process.rb', line 16 def stop_signal @stop_signal end |
#working_directory ⇒ Object (readonly)
Returns the value of attribute working_directory.
16 17 18 |
# File 'lib/aruba/processes/basic_process.rb', line 16 def working_directory @working_directory end |
Instance Method Details
#after_run ⇒ Object
Hook which is run after command is run
113 |
# File 'lib/aruba/processes/basic_process.rb', line 113 def after_run; end |
#arguments ⇒ Object
129 130 131 132 133 |
# File 'lib/aruba/processes/basic_process.rb', line 129 def arguments return Shellwords.split(commandline)[1..] if Shellwords.split(commandline).size > 1 [] end |
#before_run ⇒ Object
Hook which is run before command is run
110 |
# File 'lib/aruba/processes/basic_process.rb', line 110 def before_run; end |
#close_io ⇒ Object
68 69 70 |
# File 'lib/aruba/processes/basic_process.rb', line 68 def close_io(*) raise NotImplementedError end |
#command ⇒ Object
125 126 127 |
# File 'lib/aruba/processes/basic_process.rb', line 125 def command Shellwords.split(commandline).first end |
#commandline ⇒ Object
Return command line
38 39 40 |
# File 'lib/aruba/processes/basic_process.rb', line 38 def commandline @cmd end |
#content ⇒ Object
80 81 82 |
# File 'lib/aruba/processes/basic_process.rb', line 80 def content raise NotImplementedError end |
#empty? ⇒ Boolean
135 136 137 |
# File 'lib/aruba/processes/basic_process.rb', line 135 def empty? false end |
#filesystem_status ⇒ Object
76 77 78 |
# File 'lib/aruba/processes/basic_process.rb', line 76 def filesystem_status raise NotImplementedError end |
#inspect ⇒ Object Also known as: to_s
115 116 117 118 119 120 121 |
# File 'lib/aruba/processes/basic_process.rb', line 115 def inspect out = truncate(stdout(wait_for_io: 0).inspect, 35) err = truncate(stderr(wait_for_io: 0).inspect, 35) fmt = '#<%s:%s commandline="%s": stdout=%s stderr=%s>' format fmt, self.class, object_id, commandline, out, err end |
#output(opts = {}) ⇒ Object
Output stderr and stdout
48 49 50 |
# File 'lib/aruba/processes/basic_process.rb', line 48 def output(opts = {}) stdout(opts) + stderr(opts) end |
#pid ⇒ Object
Output pid of process
43 44 45 |
# File 'lib/aruba/processes/basic_process.rb', line 43 def pid raise NotImplementedError end |
#restart ⇒ Object
Restart a command
89 90 91 92 |
# File 'lib/aruba/processes/basic_process.rb', line 89 def restart stop start end |
#send_signal ⇒ Object
72 73 74 |
# File 'lib/aruba/processes/basic_process.rb', line 72 def send_signal(*) raise NotImplementedError end |
#started? ⇒ Boolean
Was process already started
100 101 102 |
# File 'lib/aruba/processes/basic_process.rb', line 100 def started? @started == true end |
#stderr ⇒ Object
64 65 66 |
# File 'lib/aruba/processes/basic_process.rb', line 64 def stderr(*) raise NotImplementedError end |
#stdin ⇒ Object
56 57 58 |
# File 'lib/aruba/processes/basic_process.rb', line 56 def stdin(*) raise NotImplementedError end |
#stdout ⇒ Object
60 61 62 |
# File 'lib/aruba/processes/basic_process.rb', line 60 def stdout(*) raise NotImplementedError end |
#stopped? ⇒ Boolean
Was process already stopped
95 96 97 |
# File 'lib/aruba/processes/basic_process.rb', line 95 def stopped? @started == false end |
#timed_out? ⇒ Boolean
Does the process failed to stop in time
105 106 107 |
# File 'lib/aruba/processes/basic_process.rb', line 105 def timed_out? @timed_out == true end |
#wait ⇒ Object
84 85 86 |
# File 'lib/aruba/processes/basic_process.rb', line 84 def wait raise NotImplementedError end |
#write ⇒ Object
52 53 54 |
# File 'lib/aruba/processes/basic_process.rb', line 52 def write(*) raise NotImplementedError end |