Class: Acouchi::ProcessLauncher
- Inherits:
-
Object
- Object
- Acouchi::ProcessLauncher
- Defined in:
- lib/acouchi/process_launcher.rb
Constant Summary collapse
- DEFAULT_START_OPTIONS =
{:inherit_io => true}
Instance Method Summary collapse
-
#initialize(*arguments) ⇒ ProcessLauncher
constructor
A new instance of ProcessLauncher.
- #start ⇒ Object
- #start_and_crash_if_process_fails ⇒ Object
- #start_in_background ⇒ Object
- #wait ⇒ Object
- #with_inherited_io ⇒ Object
Constructor Details
#initialize(*arguments) ⇒ ProcessLauncher
Returns a new instance of ProcessLauncher.
7 8 9 10 11 |
# File 'lib/acouchi/process_launcher.rb', line 7 def initialize(*arguments) @arguments = arguments @process = ChildProcess.build(*@arguments) self end |
Instance Method Details
#start ⇒ Object
18 19 20 21 |
# File 'lib/acouchi/process_launcher.rb', line 18 def start @process.start self end |
#start_and_crash_if_process_fails ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/acouchi/process_launcher.rb', line 33 def start_and_crash_if_process_fails start.wait if @process.crashed? raise "A process exited with a non-zero exit code.\nThe command executed was \"#{@arguments.join(" ")}\"" end self end |
#start_in_background ⇒ Object
28 29 30 31 |
# File 'lib/acouchi/process_launcher.rb', line 28 def start_in_background @process.start self end |
#wait ⇒ Object
23 24 25 26 |
# File 'lib/acouchi/process_launcher.rb', line 23 def wait @process.wait self end |
#with_inherited_io ⇒ Object
13 14 15 16 |
# File 'lib/acouchi/process_launcher.rb', line 13 def with_inherited_io @process.io.inherit! self end |