Module: SHExecutor

Defined in:
lib/shexecutor.rb,
lib/shexecutor/version.rb

Defined Under Namespace

Classes: Executor

Constant Summary collapse

VERSION =
"0.0.22"
@@default_options =
{
  :timeout => -1,                     # Seconds after which to raise Timeout::Error if not completed
  :protect_against_injection => true, # look for spaces in and tainted application path
  :stdout_path => nil,                # file to append stdout to
  :stderr_path => nil,                # file to append stderr to
  :append_stdout_path => true,        # if true, will append, otherwise will overwrite
  :append_stderr_path => true,        # if true, will append, otherwise will overwrite
  :replace => false,                  # replace the running process with the command
  :wait_for_completion => false,      # block until the command completes
  :timeout_sig_kill_retry => 500      # if timeout occurs, send TERM, and send signal 9 if still present after X ms
}

Class Method Summary collapse

Class Method Details

.default_optionsObject



17
18
19
# File 'lib/shexecutor.rb', line 17

def self.default_options
  @@default_options
end

.execute_and_timeout_after(application_path, params = nil, timeout = -1)) ⇒ Object



28
29
30
31
32
33
# File 'lib/shexecutor.rb', line 28

def self.execute_and_timeout_after(application_path, params = nil, timeout = -1)
  executor = SHExecutor::Executor.new({:timeout => timeout, :wait_for_completion => true, :application_path => application_path, :params => params})
  result = executor.execute
  executor.flush
  return result, executor.stdout, executor.stderr
end

.execute_blocking(application_path, params = nil) ⇒ Object



21
22
23
24
25
26
# File 'lib/shexecutor.rb', line 21

def self.execute_blocking(application_path, params = nil)
  executor = SHExecutor::Executor.new({:wait_for_completion => true, :application_path => application_path, :params => params})
  result = executor.execute
  executor.flush
  return result, executor.stdout, executor.stderr
end

.execute_non_blocking(application_path, params = nil) ⇒ Object



35
36
37
38
# File 'lib/shexecutor.rb', line 35

def self.execute_non_blocking(application_path, params = nil)
    executor = SHExecutor::Executor.new({:wait_for_completion => false, :application_path => application_path, :params => params})
   executor.execute
end