-
-
Save chatman-media/7716722 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| group :production do | |
| gem 'unicorn' | |
| # Enable gzip compression on heroku, but don't compress images. | |
| gem 'heroku-deflater' | |
| # Heroku injects it if it's not in there already | |
| gem 'rails_12factor' | |
| end | |
| gem 'memcachier' | |
| gem 'dalli' | |
| # Fast IO for memcache | |
| gem 'kgio' | |
| # Serve static assets through Rack + Memcache | |
| # https://devcenter.heroku.com/articles/rack-cache-memcached-rails31 | |
| gem 'rack-cache' |
This file contains hidden or 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
| web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb |
This file contains hidden or 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
| # config/environments/production.rb | |
| # ... | |
| # Enable Rails's static asset server for Heroku | |
| config.serve_static_assets = true | |
| # Set static assets cache header. rack-cache will cache those. | |
| config.static_cache_control = "public, max-age=31536000" | |
| config.cache_store = :dalli_store | |
| client = Dalli::Client.new(ENV["MEMCACHIER_SERVERS"], | |
| :value_max_bytes => 10485760, | |
| :expires_in => 1.day) | |
| # Configure rack-cache for using memcachier | |
| config.action_dispatch.rack_cache = { | |
| :metastore => client, | |
| :entitystore => client | |
| } | |
| # Send emails via sendgrid | |
| config.action_mailer.smtp_settings = { | |
| :address => 'smtp.sendgrid.net', | |
| :port => '587', | |
| :authentication => :plain, | |
| :user_name => ENV['SENDGRID_USERNAME'], | |
| :password => ENV['SENDGRID_PASSWORD'], | |
| :domain => 'heroku.com', | |
| :enable_starttls_auto => true | |
| } | |
| # ... | |
This file contains hidden or 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
| # config/unicorn.rb | |
| worker_processes 3 | |
| timeout 30 | |
| preload_app true | |
| before_fork do |server, worker| | |
| # Replace with MongoDB or whatever | |
| if defined?(ActiveRecord::Base) | |
| ActiveRecord::Base.connection.disconnect! | |
| Rails.logger.info('Disconnected from ActiveRecord') | |
| end | |
| # If you are using Redis but not Resque, change this | |
| if defined?(Resque) | |
| Resque.redis.quit | |
| Rails.logger.info('Disconnected from Redis') | |
| end | |
| sleep 1 | |
| end | |
| after_fork do |server, worker| | |
| # Replace with MongoDB or whatever | |
| if defined?(ActiveRecord::Base) | |
| ActiveRecord::Base.establish_connection | |
| Rails.logger.info('Connected to ActiveRecord') | |
| end | |
| # If you are using Redis but not Resque, change this | |
| if defined?(Resque) | |
| Resque.redis = ENV['REDIS_URI'] | |
| Rails.logger.info('Connected to Redis') | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment