Class: Rack::Handler::RaptorIO

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/handler/raptor-io.rb

Overview

Class Method Summary collapse

Class Method Details

.run(app, options = {}) {|@server| ... } ⇒ Object

Starts the server and runs the ‘app`.

Parameters:

  • app (#call)

    Rack Application to run.

  • options (Hash) (defaults to: {})

    Rack options.

Yields:

  • (@server)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rack/handler/raptor-io.rb', line 15

def self.run( app, options = {} )
  return false if @server

  options[:address]  = options.delete(:Host) || default_host
  options[:port]   ||= options.delete(:Port) || 8080

  @app    = app
  @server = ::RaptorIO::Protocol::HTTP::Server.new( options ) do |response|
    service response
  end
  yield @server if block_given?
  @server.run

  true
end

.shutdownObject

Shuts down the server.



32
33
34
35
36
37
38
39
# File 'lib/rack/handler/raptor-io.rb', line 32

def self.shutdown
  return false if !@server

  @server.stop
  @server = nil

  true
end