Skip to content

Instantly share code, notes, and snippets.

@vadviktor
Forked from subelsky/puma_rails_heroku.rb
Created February 26, 2017 00:05
Show Gist options
  • Save vadviktor/bb2daf2902c3611c561f8c4fdce83f55 to your computer and use it in GitHub Desktop.
Save vadviktor/bb2daf2902c3611c561f8c4fdce83f55 to your computer and use it in GitHub Desktop.
Setting up Puma and Rails on Heroku
# Gemfile
gem "puma"
# Procfile
web: bundle exec puma -p $PORT -e $RACK_ENV -C config/puma.rb
# add to config block config/environments/production.rb
config.threadsafe!
# get rid of NewRelic after_fork code, if you were doing this:
# http://support.newrelic.com/kb/troubleshooting/unicorn-no-data
# and get rid of config/unicorn.rb if you were using that
# config/puma.rb
require "active_record"
cwd = File.dirname(__FILE__)+"/.."
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
ActiveRecord::Base.establish_connection(ENV["DATABASE_URL"] || YAML.load_file("#{cwd}/config/database.yml")[ENV["RACK_ENV"]])
ActiveRecord::Base.verify_active_connections!
# if you use NewRelic, set your NEWRELIC_DISPATCHER environment variable on heroku, per
# https://github.com/puma/puma/issues/128 - may not be needed for future releases of Puma
heroku config:add NEWRELIC_DISPATCHER=Puma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment