Class: Aruba::Processes::BasicProcess

Inherits:
Object
  • Object
show all
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

DebugProcess, InProcess, SpawnProcess

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd, exit_timeout, io_wait_timeout, working_directory, environment = ENV.to_hash.dup, main_class = nil, stop_signal = nil, startup_wait_time = 0) ⇒ BasicProcess

Returns a new instance of BasicProcess.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/aruba/processes/basic_process.rb', line 16

def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, environment = ENV.to_hash.dup, 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
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def environment
  @environment
end

#exit_statusObject (readonly)

Returns the value of attribute exit_status.



14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def exit_status
  @exit_status
end

#exit_timeoutObject (readonly)

Returns the value of attribute exit_timeout.



14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def exit_timeout
  @exit_timeout
end

#io_wait_timeoutObject (readonly)

Returns the value of attribute io_wait_timeout.



14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def io_wait_timeout
  @io_wait_timeout
end

#main_classObject (readonly)

Returns the value of attribute main_class.



14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def main_class
  @main_class
end

#startup_wait_timeObject (readonly)

Returns the value of attribute startup_wait_time.



14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def startup_wait_time
  @startup_wait_time
end

#working_directoryObject (readonly)

Returns the value of attribute working_directory.



14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def working_directory
  @working_directory
end

Instance Method Details

#after_runObject

Hook which is run after command is run



115
# File 'lib/aruba/processes/basic_process.rb', line 115

def after_run; end

#before_runObject

Hook which is run before command is run



112
# File 'lib/aruba/processes/basic_process.rb', line 112

def before_run; end

#close_ioObject



62
63
64
# File 'lib/aruba/processes/basic_process.rb', line 62

def close_io(*)
  NotImplementedError
end

#commandlineObject

Return command line



32
33
34
# File 'lib/aruba/processes/basic_process.rb', line 32

def commandline
  @cmd
end

#contentObject



74
75
76
# File 'lib/aruba/processes/basic_process.rb', line 74

def content
  NotImplementedError
end

#filesystem_statusObject



70
71
72
# File 'lib/aruba/processes/basic_process.rb', line 70

def filesystem_status
  NotImplementedError
end

#inspectObject Also known as: to_s



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/aruba/processes/basic_process.rb', line 117

def inspect
  out = stdout(:wait_for_io => 0) + stderr(:wait_for_io => 0)

  out = if out.length > 76
          out[0, 75] + ' ...'
        else
          out
        end

  format '#<%s:%s commandline="%s": output="%s">', self.class, self.object_id, commandline, out
end

#output(opts = {}) ⇒ Object

Output stderr and stdout



42
43
44
# File 'lib/aruba/processes/basic_process.rb', line 42

def output(opts = {})
  stdout(opts) + stderr(opts)
end

#pidObject

Output pid of process



37
38
39
# File 'lib/aruba/processes/basic_process.rb', line 37

def pid
  'No implemented'
end

#restartObject

Restart a command



83
84
85
86
# File 'lib/aruba/processes/basic_process.rb', line 83

def restart
  stop
  start
end

#run!Object

Deprecated.


105
106
107
108
109
# File 'lib/aruba/processes/basic_process.rb', line 105

def run!
  Aruba.platform.deprecated('The use of "command#run!" is deprecated. You can simply use "command#start" instead.')

  start
end

#send_signalObject



66
67
68
# File 'lib/aruba/processes/basic_process.rb', line 66

def send_signal(*)
  NotImplementedError
end

#started?Boolean

Was process already started

Returns:

  • (Boolean)


94
95
96
# File 'lib/aruba/processes/basic_process.rb', line 94

def started?
  @started == true
end

#stderrObject



58
59
60
# File 'lib/aruba/processes/basic_process.rb', line 58

def stderr(*)
  NotImplementedError
end

#stdinObject



50
51
52
# File 'lib/aruba/processes/basic_process.rb', line 50

def stdin(*)
  NotImplementedError
end

#stdoutObject



54
55
56
# File 'lib/aruba/processes/basic_process.rb', line 54

def stdout(*)
  NotImplementedError
end

#stopped?Boolean

Was process already stopped

Returns:

  • (Boolean)


89
90
91
# File 'lib/aruba/processes/basic_process.rb', line 89

def stopped?
  @started == false
end

#timed_out?Boolean

Does the process failed to stop in time

Returns:

  • (Boolean)


99
100
101
# File 'lib/aruba/processes/basic_process.rb', line 99

def timed_out?
  @timed_out == true
end

#waitObject



78
79
80
# File 'lib/aruba/processes/basic_process.rb', line 78

def wait
  NotImplementedError
end

#writeObject



46
47
48
# File 'lib/aruba/processes/basic_process.rb', line 46

def write(*)
  NotImplementedError
end