Proposal: Use Rack::Handler for PreviewServer
le0pard opened this issue · comments
Hello.
I have idea, but before contribution to it, I need confirm it is good one.
As I can see PreviewServer using webrick (which is logical - no need additional dependency in project). But we can allow end customer to select, which webserver they want to use for preview. As I can see sinatra gem is using Rack::Handler
to select best available web server.
I did check, and looks like middleman can work in similar way:
- @webrick ||= setup_webrick(@options[:debug] || false)
rack_app = ::Middleman::Rack.new(@app).to_app
- @webrick.mount '/', ::Rack::Handler::WEBrick, rack_app
+ @server = ::Rack::Handler.get(server_information.server) || ::Rack::Handler.default
+ @server.run rack_app
we can provide ability for user set server from server_information
, like [:server] = :puma
or ::Rack::Handler.default
will try to use best one available - https://github.com/rack/rack/blob/master/lib/rack/handler.rb#L50-L59
Looks like also need more work with server configuration (ssl, logging, etc), that is why I ask if this is good idea before start contributing to it.
Thanks
Seems interesting. I like the inverted control of the server used coming from Rack
Thanks @tdreyno I will try make as good as possible PR for this change