Class: Merb::Rack::WEBrick

Inherits:
AbstractAdapter show all
Defined in:
merb-core/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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def server
  @server
end

Class Method Details

.new_server(port) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'merb-core/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



32
33
34
35
36
# File 'merb-core/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



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

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