lib/lotus/commands/server.rb in lotusrb-0.5.0 vs lib/lotus/commands/server.rb in lotusrb-0.6.0
- old
+ new
@@ -17,47 +17,61 @@
# @since 0.1.0
# @api private
class Server < ::Rack::Server
attr_reader :options
- def initialize(env)
- @_env = env
+ # @param options [Hash] Environment's options
+ #
+ # @since 0.1.0
+ # @see Lotus::Environment#initialize
+ def initialize(options)
+ @_env = Lotus::Environment.new(options)
@options = _extract_options(@_env)
if code_reloading?
require 'shotgun'
@app = Shotgun::Loader.new(@_env.rackup.to_s)
end
end
# Primarily this removes the ::Rack::Chunked middleware
# which is the cause of Safari content-length bugs.
+ #
+ # @since 0.1.0
def middleware
mw = Hash.new { |e, m| e[m] = [] }
mw["deployment"].concat([::Rack::ContentLength, ::Rack::CommonLogger])
mw["development"].concat(mw["deployment"] + [::Rack::ShowExceptions, ::Rack::Lint])
mw
end
+ # Kickstart shotgun preloader if code reloading is supported
+ #
+ # @since 0.1.0
def start
if code_reloading?
Shotgun.enable_copy_on_write
Shotgun.preload
end
super
end
private
+
+ # @since 0.1.0
+ # @api private
def _extract_options(env)
env.to_options.merge(
config: env.rackup.to_s,
Host: env.host,
Port: env.port,
AccessLog: []
)
end
+ # @since 0.1.0
+ # @api private
def code_reloading?
@_env.code_reloading?
end
end
end