Class: Rundoc::CodeCommand::Background::Start
Constant Summary
NEWLINE
Instance Attribute Summary
#command, #contents, #keyword, #original_args, #render_command, #render_result
Instance Method Summary
collapse
#hidden?, #not_hidden?, #push
Constructor Details
#initialize(command, name:, wait: nil, timeout: 5, log: Tempfile.new("log"), out: "2>&1", allow_fail: false) ⇒ Start
Returns a new instance of Start.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/rundoc/code_command/background/start.rb', line 5
def initialize(command, name:, wait: nil, timeout: 5, log: Tempfile.new("log"), out: "2>&1", allow_fail: false)
@command = command
@name = name
@wait = wait
@allow_fail = allow_fail
FileUtils.touch(log)
@spawn = ProcessSpawn.new(
@command,
timeout: timeout,
log: log,
out: out
)
puts "Spawning commmand: `#{@spawn.command}`"
ProcessSpawn.add(@name, @spawn)
end
|
Instance Method Details
#alive? ⇒ Boolean
33
34
35
|
# File 'lib/rundoc/code_command/background/start.rb', line 33
def alive?
!!@spawn.alive?
end
|
#call(env = {}) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/rundoc/code_command/background/start.rb', line 26
def call(env = {})
@spawn.wait(@wait)
@spawn.check_alive! unless @allow_fail
@spawn.log.read
end
|
#to_md(env = {}) ⇒ Object
22
23
24
|
# File 'lib/rundoc/code_command/background/start.rb', line 22
def to_md(env = {})
"$ #{@command}"
end
|