【问题标题】:how can i change heroku databse / hosting我如何更改 heroku 数据库/托管
【发布时间】:2016-03-01 20:39:22
【问题描述】:

我想将我的 heroku 数据库更改为允许并发连接的东西,因为我的网站正在获得一些流量,并且在多个用户尝试访问该网站时似乎崩溃了。我已经考虑将我的数据库更改为独角兽,但不确定这是否是我真正需要的。我是初学者,对我需要做什么的任何见解都将非常有用!

我的宝石文件:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.8'
# Use sqlite3 as the database for Active Record

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'bootstrap-sass'

group :production do 
    gem 'pg'
    gem 'rails_12factor'    
end

group :development, :test do
    gem 'sqlite3'
end

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]

【问题讨论】:

  • Unicorn 不是数据库,而是应用服务器。问题不太可能出在您的数据库上。运行 heroku logs -t 并尝试重现崩溃作为开始调试问题的地方。是什么让你相信数据库是问题所在。如果您正在考虑更改应用服务器,puma 是一个不错的选择,并且通常会比 unicorn 为您提供更好的性能。 Heroku 现在推荐 puma。
  • 啊哈,是的,糟糕的措辞!我想将我的应用服务器更改为 puma。有没有办法做到这不是太糟糕的技术?我的github是github.com/westche/drinkPGH
  • 移至下面的答案。

标签: postgresql heroku unicorn pg


【解决方案1】:

设置 puma 非常简单。按照这个一步一步来:https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server

也就是说,我会更深入地挖掘。无论如何,换成 puma 都是值得的,但这可能不是您问题的根源。应用程序崩溃的原因可能有很多。

这里还有 puma 文档,以防万一:https://github.com/puma/puma

【讨论】:

  • 如果我使用 PUMA,有什么方法可以在 heroku 中查看?
  • 是的。在启动时,它通常会告诉您类似...“puma 在集群模式下启动...”
  • 是的——或者如果你在本地运行服务器,它也应该在日志中说明。但是执行 heroku logs -t 然后在另一个终端运行 heroku restart 你应该会看到“Puma 在集群模式下启动...”
猜你喜欢
  • 1970-01-01
  • 2020-08-05
  • 2015-11-06
  • 1970-01-01
  • 1970-01-01
  • 2012-11-01
  • 2021-01-17
  • 2011-12-30
  • 1970-01-01
相关资源
最近更新 更多