lib/simple/httpd/server.rb in simple-httpd-0.3.4 vs lib/simple/httpd/server.rb in simple-httpd-0.3.5
- old
+ new
@@ -16,22 +16,32 @@
host ||= "127.0.0.1"
URI("http://#{host}:#{port}") # validate host and port
::Simple::Httpd.logger.info "Starting httpd server on http://#{host}:#{port}/"
+ app = ::Rack::CommonLogger.new(app)
app = ::Rack::Lint.new(app) if environment != "production"
# re/AccessLog: the AccessLog setting points WEBrick's access logging to the
# NullLogger object.
#
- # Instead we'll use a combination of Rack::CommonLogger (see Simple::Httpd.app),
- # and sinatra's logger (see Simple::Httpd::BaseController).
- ::Rack::Server.start app: app,
- Host: host,
- Port: port,
- environment: environment,
- Logger: build_logger,
- AccessLog: [[NullLogger, ""]]
+ # We do not set the environment. Rack is using this to load different
+ # default middlewares (ShowException, Lint, CommonLogger) depending on
+ # the environment setting (which should be either "development" or
+ # "deployment").
+ server_opts = {
+ app: app,
+ Host: host,
+ Port: port,
+ Logger: build_logger,
+ AccessLog: [[NullLogger, ""]]
+ }
+
+ unless ::Simple::Httpd.env == "development"
+ server_opts.update workers: 4, min_threads: 4
+ end
+
+ ::Rack::Server.start server_opts
end
private
def build_logger