Class: Dolphin::RequestHandler
- Inherits:
-
Rack::Handler::Reel
- Object
- Rack::Handler::Reel
- Dolphin::RequestHandler
- Includes:
- Util
- Defined in:
- lib/dolphin/request_handler.rb
Instance Method Summary collapse
-
#initialize(host, port) ⇒ RequestHandler
constructor
A new instance of RequestHandler.
- #start ⇒ Object
- #stop ⇒ Object
Methods included from Util
Constructor Details
#initialize(host, port) ⇒ RequestHandler
Returns a new instance of RequestHandler.
12 13 14 15 |
# File 'lib/dolphin/request_handler.rb', line 12 def initialize(host, port) super({:host=>host, :port=>port, :app=>RequestApp.new}) logger :info, "Load settings in #{Dolphin.config}" end |
Instance Method Details
#start ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/dolphin/request_handler.rb', line 17 def start Celluloid::Actor[:request_handler_rack_pool] = ::Reel::RackWorker.pool(size: [:workers], args: [self]) ::Reel::Server.supervise_as(:request_handler, [:host], [:port]) do |connection| Celluloid::Actor[:request_handler_rack_pool].handle(connection.detach) end logger :info, "Running on ruby #{RUBY_VERSION} with selected #{Celluloid::task_class}" logger :info, "Listening on http://#{[:host]}:#{[:port]}" end |
#stop ⇒ Object
27 28 29 30 |
# File 'lib/dolphin/request_handler.rb', line 27 def stop Celluloid::Actor[:request_handler].terminate! Celluloid::Actor[:request_handler_rack_pool].terminate! end |