module SubZero::Runner

Public Instance Methods

run!() click to toggle source
# File lib/sub_zero/service/runner.rb, line 4
def run!
  Daemons.run_proc sid, daemon_configuration do
    start   = Time.now
    ping_at = start + 5

    Signal.trap('INT')  { socket.down!; exit }
    Signal.trap('TERM') { socket.down!; exit }

    socket.up!

    loop do
      socket.run &method(:resolve)

      now = Time.now

      if now >= ping_at
        socket.ping
        ping_at = now + 15
      end

      break if $stop_requested
    end

    socket.down!
    exit 0
  end
end