Class: Rack::Server
- Inherits:
-
Object
- Object
- Rack::Server
- Defined in:
- lib/rack/server.rb
Defined Under Namespace
Classes: Options
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #app ⇒ Object
- #default_options ⇒ Object
-
#initialize(options = nil) ⇒ Server
constructor
A new instance of Server.
- #middleware ⇒ Object
- #server ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Server
Returns a new instance of Server.
88 89 90 |
# File 'lib/rack/server.rb', line 88 def initialize( = nil) @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
86 87 88 |
# File 'lib/rack/server.rb', line 86 def @options end |
Class Method Details
.middleware ⇒ Object
119 120 121 122 123 124 125 126 |
# 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 |
.start ⇒ Object
82 83 84 |
# File 'lib/rack/server.rb', line 82 def self.start new.start end |
Instance Method Details
#app ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/rack/server.rb', line 107 def app @app ||= begin if !::File.exist? [:config] abort "configuration #{[:config]} not found" end app, = Rack::Builder.parse_file(self.[:config], opt_parser) self..merge! app end end |
#default_options ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rack/server.rb', line 96 def { :environment => "development", :pid => nil, :Port => 9292, :Host => "0.0.0.0", :AccessLog => [], :config => "config.ru" } end |
#middleware ⇒ Object
128 129 130 |
# File 'lib/rack/server.rb', line 128 def middleware self.class.middleware end |
#server ⇒ Object
158 159 160 |
# File 'lib/rack/server.rb', line 158 def server @_server ||= Rack::Handler.get([:server]) || Rack::Handler.default end |
#start ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/rack/server.rb', line 132 def start if [:debug] $DEBUG = true require 'pp' p [:server] pp wrapped_app pp app end if [:warn] $-w = true end if includes = [:include] $LOAD_PATH.unshift *includes end if library = [:require] require library end daemonize_app if [:daemonize] write_pid if [:pid] server.run wrapped_app, end |