class Rundoc::CodeCommand::Background::Start
Public Class Methods
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) @timeout = timeout @command = command @name = name @wait = wait @allow_fail = allow_fail @log = log @redirect = out FileUtils.touch(@log) @background = nil end
Public Instance Methods
Source
# File lib/rundoc/code_command/background/start.rb, line 41 def alive? !!background.alive? end
Source
# File lib/rundoc/code_command/background/start.rb, line 18 def background @background ||= ProcessSpawn.new( @command, timeout: @timeout, log: @log, out: @redirect ).tap do |spawn| puts "Spawning commmand: `#{spawn.command}`" ProcessSpawn.add(@name, spawn) end end
Source
# File lib/rundoc/code_command/background/start.rb, line 34 def call(env = {}) background.wait(@wait) background.check_alive! unless @allow_fail background.log.read end
Source
# File lib/rundoc/code_command/background/start.rb, line 30 def to_md(env = {}) "$ #{@command}" end