Class: Dolphin::RequestHandler

Inherits:
Rack::Handler::Reel
  • Object
show all
Includes:
Util
Defined in:
lib/dolphin/request_handler.rb

Instance Method Summary collapse

Methods included from Util

#logger

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

#startObject



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: options[:workers], args: [self])

  ::Reel::Server.supervise_as(:request_handler, options[:host], options[: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://#{options[:host]}:#{options[:port]}"
end

#stopObject



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