【发布时间】:2016-11-19 02:50:18
【问题描述】:
我正在尝试将我的 rails 应用程序部署到 heroku。该应用程序已上传,但由于某种原因无法正常运行。当我输入
heroku 运行 rake db:migrate
我收到一个错误提示
ActiveRecord::ConnectionTimeoutError: 无法在 5.000 秒内获得数据库连接(等待 5.000 秒)
我正在使用 puma 作为服务器,我将发布一些可能导致问题的文件...请询问可能导致此错误的任何内容!
config/database.ymi
production:
adapter: postgresql
host: localhost
encoding: unicode
database: FastOrder_production
pool: 5
username: <%= ENV['FASTORDER_DATABASE_USER'] %>
password: <%= ENV['FASTORDER_DATABASE_PASSWORD'] %>
template: template0
url: <%= ENV["DATABASE_URL"] %>
pool: ENV['RAILS_MAX_THREADS']
config/puma.rb
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# Worker specific setup for Rails 4.1+
# See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
ActiveRecord::Base.establish_connection
end
【问题讨论】:
-
你是否在项目文件夹下添加了procfile?如devcenter.heroku.com/articles/…所述
-
在 procfile 下他们说“但是我们建议生成一个配置文件”,我已经发布了
-
不一样。你有 config/puma.rb 但你没有
Procfile file包含此行的文件web: bundle exec puma -C config/puma.rb -
谢谢,但在创建 procfile 后我得到了同样的错误:/
标签: ruby-on-rails ruby heroku