我試圖將我的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