-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extracted Sinatra::MoreServer from BigBand
- Loading branch information
0 parents
commit d605cb7
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require "sinatra/base" | ||
|
||
module Sinatra | ||
# Adds more servers to Sinatra::Base#run! (currently unicorn and rainbows). | ||
module MoreServer | ||
autoload :Unicorn, "big_band/more_server/unicorn" | ||
autoload :Rainbows, "big_band/more_server/rainbows" | ||
def self.registered(klass) | ||
Rack::Handler.register "unicorn", "BigBand::MoreServer::Unicorn" | ||
Rack::Handler.register "rainbows", "BigBand::MoreServer::Rainbows" | ||
klass.server += "rainbows", "unicorn" | ||
end | ||
end | ||
|
||
register MoreServer | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require "sinatra/more_server/unicorn" | ||
require "rainbows" | ||
|
||
class Sinatra | ||
module MoreServer | ||
# Rack Handler to use Rainbows for Sinatra::Base.run! | ||
module Rainbows | ||
def self.run(app, options = {}) | ||
Sinatra::MoreServer::Unicorn.run app, options.merge(:Backend => ::Rainbows) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "sinatra/base" | ||
require "unicorn" | ||
require "rack/content_length" | ||
require "rack/chunked" | ||
|
||
class Sinatra | ||
module MoreServer | ||
# Rack Handler to use Unicorn for Sinatra::Base.run! | ||
module Unicorn | ||
def self.run(app, options={}) | ||
app = Rack::Builder.new do | ||
# TODO: env dependend stuff. | ||
use Rack::CommonLogger, $stderr | ||
use Rack::ShowExceptions | ||
run app | ||
end.to_app | ||
options[:Backend] ||= ::Unicorn | ||
options[:Host] ||= ::Unicorn::Const::DEFAULT_HOST | ||
options[:Port] ||= ::Unicorn::Const::DEFAULT_PORT | ||
options[:listeners] = ["#{options.delete :Host}:#{options.delete :Port}"] | ||
server = options.delete(:Backend)::HttpServer.new app, options | ||
yield server if block_given? | ||
server.start.join | ||
end | ||
end | ||
end | ||
end |