Class: Falcon::Supervisor
- Inherits:
-
Object
- Object
- Falcon::Supervisor
- Defined in:
- lib/falcon/supervisor.rb
Defined Under Namespace
Classes: Statistics
Instance Method Summary collapse
- #handle(message) ⇒ Object
-
#initialize(endpoint) ⇒ Supervisor
constructor
A new instance of Supervisor.
- #restart(message) ⇒ Object
- #run ⇒ Object
- #statistics(message) ⇒ Object
Constructor Details
#initialize(endpoint) ⇒ Supervisor
Returns a new instance of Supervisor.
68 69 70 |
# File 'lib/falcon/supervisor.rb', line 68 def initialize(endpoint) @endpoint = endpoint end |
Instance Method Details
#handle(message) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/falcon/supervisor.rb', line 85 def handle() case [:please] when 'restart' self.restart() when 'statistics' self.statistics() end end |
#restart(message) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/falcon/supervisor.rb', line 72 def restart() signal = [:signal] || :INT # Sepukku: Process.kill(signal, -Process.getpgrp) end |
#run ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/falcon/supervisor.rb', line 94 def run Async.logger.info("Binding to #{@endpoint}") @endpoint.accept do |peer| stream = Async::IO::Stream.new(peer) while = stream.gets("\0") response = handle(JSON.parse(, symbolize_names: true)) stream.puts(response.to_json, separator: "\0") end end end |
#statistics(message) ⇒ Object
79 80 81 82 83 |
# File 'lib/falcon/supervisor.rb', line 79 def statistics() statistics = Statistics.new statistics.capture end |