2/26/2017 - 12:05 AM

Setting up Puma and Rails on Heroku

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

# get rid of NewRelic after_fork code, if you were doing this:
# 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"]])

# if you use NewRelic, set your NEWRELIC_DISPATCHER environment variable on heroku, per
# - may not be needed for future releases of Puma

heroku config:add NEWRELIC_DISPATCHER=Puma