Class: Megatest::Executor::ExternalMonitor
- Inherits:
-
Object
- Object
- Megatest::Executor::ExternalMonitor
- Defined in:
- lib/megatest/executor.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ ExternalMonitor
constructor
A new instance of ExternalMonitor.
- #reap ⇒ Object
- #spawn ⇒ Object
Constructor Details
#initialize(config) ⇒ ExternalMonitor
Returns a new instance of ExternalMonitor.
27 28 29 30 31 |
# File 'lib/megatest/executor.rb', line 27 def initialize(config) require "rbconfig" @config = config spawn end |
Instance Method Details
#reap ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/megatest/executor.rb', line 33 def reap if @pipe @pipe.close @pipe = nil _, status = Process.waitpid2(@pid) @pid = nil status end end |
#spawn ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/megatest/executor.rb', line 43 def spawn child_read, @pipe = IO.pipe ready_pipe, child_write = IO.pipe @pid = Process.spawn( RbConfig.ruby, File.("../queue_monitor.rb", __FILE__), in: child_read, out: child_write, ) child_read.close Marshal.dump(@config, @pipe) # Check the process is alive. if ready_pipe.wait_readable(10) ready_pipe.gets ready_pipe.close Process.kill(0, @pid) else Process.kill(0, @pid) Process.wait(@pid) raise Error, "ExternalMonitor failed to boot" end end |