class Rack::Server

Attributes

options[RW]

Public Class Methods

middleware() click to toggle source
# File lib/rack/server.rb, line 119
def self.middleware
  @middleware ||= begin
    m = Hash.new {|h,k| h[k] = []}
    m["deployment"].concat  [lambda {|server| server.server =~ /CGI/ ? nil : [Rack::CommonLogger, $stderr] }]
    m["development"].concat m["deployment"] + [[Rack::ShowExceptions], [Rack::Lint]]
    m
  end
end
new(options = nil) click to toggle source
# File lib/rack/server.rb, line 88
def initialize(options = nil)
  @options = options
end
start() click to toggle source
# File lib/rack/server.rb, line 82
def self.start
  new.start
end

Public Instance Methods

app() click to toggle source
# File lib/rack/server.rb, line 107
def app
  @app ||= begin
    if !::File.exist? options[:config]
      abort "configuration #{options[:config]} not found"
    end

    app, options = Rack::Builder.parse_file(self.options[:config], opt_parser)
    self.options.merge! options
    app
  end
end
default_options() click to toggle source
# File lib/rack/server.rb, line 96
def default_options
  {
    :environment => "development",
    :pid         => nil,
    :Port        => 9292,
    :Host        => "0.0.0.0",
    :AccessLog   => [],
    :config      => ::File.expand_path("config.ru", Dir.pwd)
  }
end
middleware() click to toggle source
# File lib/rack/server.rb, line 128
def middleware
  self.class.middleware
end
server() click to toggle source
# File lib/rack/server.rb, line 158
def server
  @_server ||= Rack::Handler.get(options[:server]) || Rack::Handler.default
end
start() click to toggle source
# File lib/rack/server.rb, line 132
def start
  if options[:debug]
    $DEBUG = true
    require 'pp'
    p options[:server]
    pp wrapped_app
    pp app
  end

  if options[:warn]
    $-w = true
  end

  if includes = options[:include]
    $LOAD_PATH.unshift *includes
  end

  if library = options[:require]
    require library
  end

  daemonize_app if options[:daemonize]
  write_pid if options[:pid]
  server.run wrapped_app, options
end