ruby 在Heroku上设置Puma和Rails

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 在Heroku上设置Puma和Rails相关的知识,希望对你有一定的参考价值。

# 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

以上是关于ruby 在Heroku上设置Puma和Rails的主要内容,如果未能解决你的问题,请参考以下文章