Created
December 11, 2012 23:50
-
-
Save dblock/4263488 to your computer and use it in GitHub Desktop.
Conditionally disable the proxy forwarding by https://github.com/dblock/heroku-forward using the DISABLE_FORWARD_PROXY environment setting.
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
require 'rubygems' | |
require 'bundler' | |
if ENV['DISABLE_FORWARD_PROXY'] | |
eval File.read(::File.expand_path('../my_app.ru', __FILE__)) | |
else | |
$stdout.sync = true | |
Bundler.require(:rack) | |
port = (ARGV.first || ENV['PORT'] || 3000).to_i | |
env = ENV['RACK_ENV'] || 'development' | |
require 'em-proxy' | |
require 'logger' | |
require 'heroku-forward' | |
# | |
# Setup a reverse proxy for faster Heroku boot and future load-balancing. | |
# | |
application = File.expand_path('../my_app.ru', __FILE__) | |
backend = Heroku::Forward::Backends::Thin.new(application: application, env: env) | |
proxy = Heroku::Forward::Proxy::Server.new(backend, { host: '0.0.0.0', port: port }) | |
proxy.logger = Logger.new(STDOUT) | |
proxy.forward! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment