我试图将我的rails应用程序部署到heroku。该应用程序已上传,但由于某种原因无法正常运行。当我键入部署到Heroku,Rails应用程序
heroku run rake db:migrate
我得到一个错误说
ActiveRecord::ConnectionTimeoutError: could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)
我使用PUMA的服务器,我会发布一些文件,这些文件可能会导致问题...请询问任何可能会导致此错误!
配置/ 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']
配置/ 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?如所述https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server – mrvncaragay
在proc文件下他们说“但我们建议生成一个配置文件”,我发布了 –
这就是不同。你有config/puma.rb,但是你没有'Procfile file'文件包含这一行'web:bundle exec puma -C config/puma.rb' – mrvncaragay