class Falcon::Supervisor
def handle(message)
def handle(message) case message[:please] when 'restart' self.restart(message) when 'statistics' self.statistics(message) end end
def initialize(endpoint)
def initialize(endpoint) @endpoint = endpoint end
def restart(message)
def restart(message) signal = message[:signal] || :INT # Sepukku: Process.kill(signal, -Process.getpgrp) end
def run
def run Async.logger.info("Binding to #{@endpoint}") @endpoint.accept do |peer| stream = Async::IO::Stream.new(peer) while message = stream.gets("\0") response = handle(JSON.parse(message, symbolize_names: true)) stream.puts(response.to_json, separator: "\0") end end end
def statistics(message)
def statistics(message) statistics = Statistics.new statistics.capture end