Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Handy things for Heroku #37

Merged
merged 3 commits into from

2 participants

@danielmorrison
  • gzip (cedar stack doesn't do this for us)
  • rails_12factor gem
config.ru
@@ -1,4 +1,5 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
+use Rack::Deflater
@laserlemon Owner

Seems like awkward placement. What about this?

@danielmorrison Owner

Well, my method is only one line! :wink:

I guess I don't really care. I just always do it this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
danielmorrison added some commits
@danielmorrison danielmorrison Add rails_12factor gem
Required for Heroku deployments
e06add7
@danielmorrison danielmorrison Use Rack::Deflater
GZips our responses on Heroku for more speed
06bb54e
@laserlemon
Owner

:vertical_traffic_light: :bomb: on the streaming endpoint tests. Restarting…

@laserlemon
Owner

:vertical_traffic_light: :bomb: :boom: again. Could it be an issue with streaming GZipped content?

@laserlemon
Owner

Same failures locally. :frowning:

@laserlemon
Owner

:eyes: :pray: It's a bit hacky.

@danielmorrison danielmorrison merged commit 09b0ee8 into master
@danielmorrison danielmorrison deleted the heroku branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 26, 2014
  1. @danielmorrison @laserlemon

    Add rails_12factor gem

    danielmorrison authored laserlemon committed
    Required for Heroku deployments
  2. @danielmorrison @laserlemon

    Use Rack::Deflater

    danielmorrison authored laserlemon committed
    GZips our responses on Heroku for more speed
  3. @laserlemon
This page is out of date. Refresh to see the latest.
View
4 Gemfile
@@ -25,3 +25,7 @@ group :development, :test do
gem "pry-rails"
gem "rspec-rails", "~> 2.14"
end
+
+group :production do
+ gem "rails_12factor"
+end
View
6 Gemfile.lock
@@ -119,6 +119,11 @@ GEM
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.3)
sprockets-rails (~> 2.0.0)
+ rails_12factor (0.0.2)
+ rails_serve_static_assets
+ rails_stdout_logging
+ rails_serve_static_assets (0.0.2)
+ rails_stdout_logging (0.0.3)
railties (4.0.3)
actionpack (= 4.0.3)
activesupport (= 4.0.3)
@@ -198,5 +203,6 @@ DEPENDENCIES
pry-rails
puma (~> 2.7)
rails (~> 4.0.3)
+ rails_12factor
rspec-rails (~> 2.14)
twitter (~> 5.7)
View
8 config/application.rb
@@ -1,4 +1,6 @@
-require File.expand_path('../boot', __FILE__)
+require File.expand_path("../boot", __FILE__)
+
+require File.expand_path("../../lib/conditional_deflater", __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
@@ -30,5 +32,9 @@ class Application < Rails::Application
config.i18n.enforce_available_locales = true
config.middleware.insert_after ActionDispatch::ParamsParser, ActionDispatch::XmlParamsParser
+ config.middleware.use ConditionalDeflater do |env|
+ # Don't gzip streaming endpoints
+ env["PATH_INFO"] !~ %r(^/room/\d+/live)
+ end
end
end
View
16 lib/conditional_deflater.rb
@@ -0,0 +1,16 @@
+require "rack/deflater"
+
+class ConditionalDeflater
+ def initialize(app, &condition)
+ @app, @condition = app, condition
+ @deflater = Rack::Deflater.new(app)
+ end
+
+ def call(env)
+ if @condition && @condition.call(env)
+ @deflater.call(env)
+ else
+ @app.call(env)
+ end
+ end
+end
Something went wrong with that request. Please try again.