Class: Merb::Rack::WEBrick

Inherits:
AbstractAdapter show all
Defined in:
lib/merb-core/rack/adapter/webrick.rb

Class Attribute Summary collapse

Class Method Summary collapse

Methods inherited from AbstractAdapter

exit_process, process_title, spawn_worker, start, start_at_port

Class Attribute Details

.serverObject

:api: private



11
12
13
# File 'lib/merb-core/rack/adapter/webrick.rb', line 11

def server
  @server
end

Class Method Details

.new_server(port) ⇒ Object

:api: plugin



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/merb-core/rack/adapter/webrick.rb', line 15

def self.new_server(port)
  options = {
    :Port        => port,
    :BindAddress => @opts[:host],
    :Logger      => Merb.logger,
    :AccessLog   => [
      [Merb.logger, ::WEBrick::AccessLog::COMMON_LOG_FORMAT],
      [Merb.logger, ::WEBrick::AccessLog::REFERER_LOG_FORMAT]
    ]
  }

  sockets = ::WEBrick::Utils.create_listeners nil, port
  @server = ::WEBrick::HTTPServer.new(options.merge(:DoNotListen => true))
  @server.listeners.replace sockets
end

.start_serverObject

:api: plugin



32
33
34
35
36
# File 'lib/merb-core/rack/adapter/webrick.rb', line 32

def self.start_server
  @server.mount("/", ::Rack::Handler::WEBrick, @opts[:app])
  @server.start
  exit(@status)
end

.stop(status = 0) ⇒ Object

:api: plugin



39
40
41
42
# File 'lib/merb-core/rack/adapter/webrick.rb', line 39

def self.stop(status = 0)
  @status = status
  @server.shutdown
end