Class: Micron::Runner::LivenessChecker

Inherits:
Object
  • Object
show all
Includes:
Debug
Defined in:
lib/micron/runner/liveness_checker.rb,
lib/micron/runner/liveness_checker/ping.rb,
lib/micron/runner/liveness_checker/pong.rb

Defined Under Namespace

Classes: Ping, Pong

Instance Method Summary collapse

Methods included from Debug

#debug

Constructor Details

#initializeLivenessChecker

Returns a new instance of LivenessChecker.



12
13
14
15
# File 'lib/micron/runner/liveness_checker.rb', line 12

def initialize
  @ping = IO.pipe
  @pong = IO.pipe
end

Instance Method Details

#fdsObject



33
34
35
# File 'lib/micron/runner/liveness_checker.rb', line 33

def fds
  (@ping + @pong).map { |f| f.to_i }
end

#ping(pid) ⇒ Object



17
18
19
20
21
# File 'lib/micron/runner/liveness_checker.rb', line 17

def ping(pid)
  @pinger = Ping.new(@pong.first, @ping.last, pid)
  @ping.first.close
  @pong.last.close
end

#pongObject



23
24
25
26
27
# File 'lib/micron/runner/liveness_checker.rb', line 23

def pong
  @ponger = Pong.new(@ping.first, @pong.last)
  @ping.last.close
  @pong.first.close
end

#stopObject



29
30
31
# File 'lib/micron/runner/liveness_checker.rb', line 29

def stop
  @pinger.thread.kill
end