class Rundoc::CodeCommand::Background::Start

Public Class Methods

new(command, name:, wait: nil, timeout: 5, log: Tempfile.new("log"), out: "2>&1", allow_fail: false) click to toggle source
# 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
  )
  ProcessSpawn.add(@name, @spawn)
end

Public Instance Methods

alive?() click to toggle source
# File lib/rundoc/code_command/background/start.rb, line 32
def alive?
  !!@spawn.alive?
end
call(env = {}) click to toggle source
# File lib/rundoc/code_command/background/start.rb, line 25
def call(env = {})
  @spawn.wait(@wait)
  @spawn.check_alive! unless @allow_fail

  @spawn.log.read
end
to_md(env = {}) click to toggle source
# File lib/rundoc/code_command/background/start.rb, line 21
def to_md(env = {})
  "$ #{@command}"
end