Class: Rundoc::CodeCommand::Background::StartRunner
- Inherits:
-
Object
- Object
- Rundoc::CodeCommand::Background::StartRunner
- Defined in:
- lib/rundoc/code_command/background/start.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #background ⇒ Object
- #call(env = {}) ⇒ Object
-
#initialize(user_args:, render_command:, render_result:, io:, contents: nil) ⇒ StartRunner
constructor
A new instance of StartRunner.
- #to_md(env = {}) ⇒ Object
Constructor Details
#initialize(user_args:, render_command:, render_result:, io:, contents: nil) ⇒ StartRunner
Returns a new instance of StartRunner.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rundoc/code_command/background/start.rb', line 23 def initialize(user_args:, render_command:, render_result:, io:, contents: nil) @timeout = user_args.timeout @command = user_args.command @name = user_args.name @wait = user_args.wait @allow_fail = user_args.allow_fail @log = user_args.log @redirect = user_args.out FileUtils.touch(@log) @background = nil @io = io end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
21 22 23 |
# File 'lib/rundoc/code_command/background/start.rb', line 21 def io @io end |
Instance Method Details
#alive? ⇒ Boolean
60 61 62 |
# File 'lib/rundoc/code_command/background/start.rb', line 60 def alive? !!background.alive? end |
#background ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rundoc/code_command/background/start.rb', line 37 def background @background ||= ProcessSpawn.new( @command, timeout: @timeout, log: @log, out: @redirect ).tap do |spawn| io.puts "Spawning commmand: `#{spawn.command}`" ProcessSpawn.add(@name, spawn) end end |
#call(env = {}) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/rundoc/code_command/background/start.rb', line 53 def call(env = {}) background.wait(@wait) background.check_alive! unless @allow_fail background.log.read end |
#to_md(env = {}) ⇒ Object
49 50 51 |
# File 'lib/rundoc/code_command/background/start.rb', line 49 def to_md(env = {}) "$ #{@command}" end |