Class: DaemonRunner::ShellOut
- Inherits:
-
Object
- Object
- DaemonRunner::ShellOut
- Defined in:
- lib/daemon_runner/shell_out.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#cwd ⇒ Object
readonly
Returns the value of attribute cwd.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#valid_exit_codes ⇒ Object
readonly
Returns the value of attribute valid_exit_codes.
-
#wait ⇒ Object
readonly
Returns the value of attribute wait.
Class Method Summary collapse
-
.wait2(pid = nil, flags = 0) ⇒ Process::Status?
Wait for the process with the given pid to finish.
Instance Method Summary collapse
-
#initialize(command: nil, cwd: '/tmp', timeout: 15, wait: true, valid_exit_codes: [0]) ⇒ ShellOut
constructor
A new instance of ShellOut.
-
#run! ⇒ Mixlib::ShellOut, Fixnum
Run command.
-
#wait2(flags = 0) ⇒ Process::Status?
Wait for the process to finish.
Constructor Details
#initialize(command: nil, cwd: '/tmp', timeout: 15, wait: true, valid_exit_codes: [0]) ⇒ ShellOut
Returns a new instance of ShellOut.
24 25 26 27 28 29 30 |
# File 'lib/daemon_runner/shell_out.rb', line 24 def initialize(command: nil, cwd: '/tmp', timeout: 15, wait: true, valid_exit_codes: [0]) @command = command @cwd = cwd @timeout = timeout @wait = wait @valid_exit_codes = valid_exit_codes end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
6 7 8 |
# File 'lib/daemon_runner/shell_out.rb', line 6 def command @command end |
#cwd ⇒ Object (readonly)
Returns the value of attribute cwd.
6 7 8 |
# File 'lib/daemon_runner/shell_out.rb', line 6 def cwd @cwd end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
5 6 7 |
# File 'lib/daemon_runner/shell_out.rb', line 5 def stdout @stdout end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/daemon_runner/shell_out.rb', line 6 def timeout @timeout end |
#valid_exit_codes ⇒ Object (readonly)
Returns the value of attribute valid_exit_codes.
6 7 8 |
# File 'lib/daemon_runner/shell_out.rb', line 6 def valid_exit_codes @valid_exit_codes end |
#wait ⇒ Object (readonly)
Returns the value of attribute wait.
6 7 8 |
# File 'lib/daemon_runner/shell_out.rb', line 6 def wait @wait end |
Class Method Details
.wait2(pid = nil, flags = 0) ⇒ Process::Status?
Wait for the process with the given pid to finish
12 13 14 15 16 17 |
# File 'lib/daemon_runner/shell_out.rb', line 12 def self.wait2(pid = nil, flags = 0) return nil if pid.nil? Process.wait2(pid, flags)[1] rescue Errno::ECHILD nil end |
Instance Method Details
#run! ⇒ Mixlib::ShellOut, Fixnum
Run command
34 35 36 37 38 39 40 41 |
# File 'lib/daemon_runner/shell_out.rb', line 34 def run! validate_command if wait run_and_wait else run_and_detach end end |
#wait2(flags = 0) ⇒ Process::Status?
Wait for the process to finish
46 47 48 |
# File 'lib/daemon_runner/shell_out.rb', line 46 def wait2(flags = 0) self.class.wait2(@pid, flags) end |