- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我用他们内置的数据库 SQLITE 3 构建了一个 Rails 应用程序。我已经尝试了一段时间将应用程序部署到 Heroku。我知道 Heroku 的首选数据库是 Postgres,所以我经历了将应用程序的数据库从 SQLITE 更改为 postgres 的麻烦。
这是我的 Gemfile,它指定我现在安装了“pg”而不是 sqlite。
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
ruby '2.1.0'
gem 'rails', '4.1.1'
group :development, :test do
gem 'pg', '0.17.1'
gem 'rspec-rails', '3.0.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '~> 4.0.2'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'sprockets-rails', '~> 2.1.3'
gem 'bootstrap-sass', '3.1.1.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.1.1'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
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', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
我最近安装了很多次 gem pg 以确保它已安装。运行 psql --version 给我以下信息
psql (PostgreSQL) 9.3.4
运行 which psql 显示目录
/usr/local/bin/psql
在从 SQLite 转换到 Postgres 的过程中,我尽可能地更新了我的 database.yml 文件。
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: postgresql
encoding: unicode
database: games_development
pool: 5
timeout: 5000
host: localhost
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
database: games_test
pool: 5
timeout: 5000
production:
adapter: postgresql
database: games_production
pool: 5
timeout: 5000
如您所见,我将适配器从 sqlite3 更改为 postgresql,如 Heroku Dev Center 网站上所示。我用以下格式命名我的数据库。三个环境的appname_environement
我什至为开发环境添加了 host:localhost。
这是我在运行 cat pg_hba.conf 时收到的输出
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication edited trust
#host replication edited 127.0.0.1/32 trust
#host replication edited ::1/128 trust
现在我想描述一下我的问题。我可以成功部署到 Heroku,但在运行 heroku open 时收到以下错误消息。
Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
我的下一步是运行 heroku logs 命令。
2014-06-19T16:14:31.269890+00:00 app[web.1]: => Booting WEBrick
2014-06-19T16:14:31.269894+00:00 app[web.1]: => Rails 4.1.1 application starting in production on http://0.0.0.0:36743
2014-06-19T16:14:31.269896+00:00 app[web.1]: => Run `rails server -h` for more startup options
2014-06-19T16:14:31.269898+00:00 app[web.1]: => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
2014-06-19T16:14:31.269899+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-06-19T16:14:31.269901+00:00 app[web.1]: Exiting
2014-06-19T16:14:32.519139+00:00 heroku[web.1]: State changed from starting to crashed
2014-06-19T16:14:32.507573+00:00 heroku[web.1]: Process exited with status 1
2014-06-19T16:17:43.026380+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-anchorage-9017.herokuapp.com request_id=d2e55388-dbe6-439e-bba5-2f3f18eb3744 fwd="24.14.65.222" dyno= connect= service= status=503 bytes=
根据我对上述输出的理解,它首先在生产开发中运行 WEBrick 服务器。我确实知道我的“pg”gem 在我的 Gemfile 中指示的开发和测试环境中。我认为这可能是个问题。输出显示服务器正在退出,状态为 1。最后一行是金色的,这向我表明存在问题。
阅读该错误消息时,我看到错误代码 H10 以及描述“APP crashed”。继续前进,它显示状态代码 503,表示服务器出现问题。
我尝试运行 rake db:rollback 命令来重置数据库。
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5432?
/Users/edited/.rvm/gems/ruby-2.1.0/gems/activerecord- 4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:881:in `initialize'
/Users/edited/.rvm/gems/ruby-2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:881:in `new'
/Users/edited/.rvm/gems/ruby-2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:881:in `connect'
/Users/edited/.rvm/gems/ruby-2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
/Users/edited/.rvm/gems/ruby-2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/Users/edited/.rvm/gems/ruby-2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
我立即注意到的一件事是它指示连接错误,它无法连接到服务器。我还注意到它指示端口 5432,而本地主机的公共(public)端口是 3000。消息随后显示了问题的踪迹,这似乎主要在 connection_adapter/postgresql_adapter 中。
上面的错误消息也显示在 rake db:migrate、rails c-sandbox、rails c 命令和 rails s 上。
我承认,当我创建这个应用程序时,它是在 sqlite 中创建的,因此可能会导致一些问题。但是,由于我需要将应用程序推送到 Heroku,因此我不得不将数据库更改为 postgres。
老实说,我觉得我已经用尽了所有的选择。我别无选择,只能在这里问这个问题。非常感谢任何建议。
最佳答案
希望这能解决您遇到的问题..
我注意到您没有在您的 gemfile 中为生产环境指定 postgresql gem。您仅为开发和测试环境指定了它。
将以下内容添加到您的 gemfile 中:
group :production do
gem 'pg'
gem 'rails_12factor'
end
'rails_12factor' gem 支持静态 Assets 服务和 Heroku 中的日志记录等功能,因为它们已从 Rails 4 中删除。
部署到 Heroku 时,您的应用无需在开发环境中运行 Postgresql 即可在 Heroku 上的生产环境中运行。
如果上述方法不起作用,此资源也可能有所帮助。祝一切顺利!
https://devcenter.heroku.com/articles/getting-started-with-rails4
关于ruby-on-rails - Heroku - 从 Sqlite 迁移到 Postgres 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24295333/
我正在尝试使用 Heroku Scheduler 在已部署的 Heroku 应用程序中调用 HTTP 端点,它基本上以固定速率在 Heroku bash 上运行命令。 当我运行 $ heroku ru
我有一个在 Heroku 上运行的应用程序,其中有一些我想不时更改的设置,并且我想使用 Heroku 配置变量来存储这些设置,以便它们持久存在。 我知道我可以从 Heroku 仪表板或 Heroku
我从模板 reagent-frontend 创建了一个 ClojureScript Reagent 应用程序。如何将生产应用程序部署到 Heroku?在为生产构建后(lein package/lein
我正在尝试在 heroku 上添加信用卡,然后消息显示“无法验证您的卡,请稍后再试或联系您的金融机构寻求帮助” 最佳答案 这是因为您的银行拒绝付款。 检查您是否输入了所有正确的详细信息 查看您银行的最
首先为我的英语感到抱歉,因为它不是我的母语,我不习惯它,它可能很难理解。 我正在尝试将我的 spike 应用程序连接到 heroku 以获取长期葡萄糖数据。 我在没有“部署分支”步骤的情况下成功完成了
Ec2 实例小时按小时计算。如果你只是启动和关闭一个实例,它仍然算作一小时。 Heroku 如何处理这个?按分钟还是按小时? 让我们假设我的应用程序使用超过 750 免费 Dyno 小时限制 最佳答案
好奇 heroku 如何创建应用程序名称。应用程序名称通常是英文单词,例如bloom-peaks 或formal-trail。一家大公司的 IT 部门也是如此。是否有用于名称生成的 unix 库? 最
有没有人在 Heroku 上成功使用过 docsplit?它有许多二进制依赖项。我已经搜索过,但没有找到任何人这样做。教程会很棒,但我真的很好奇其他人是否成功。 最佳答案 我的搜索没有找到任何做过这件
我想将一个应用程序部署到需要能够生成加密安全随机数的 heroku。我可以使用哪些熵源? 最佳答案 你的 Heroku dyno 基本上是一个 Ubuntu 服务器虚拟机,所以你应该可以访问 /dev
Heroku 可以显示自定义维护页面: heroku config:set MAINTENANCE_PAGE_URL=http://some_server/my_page.html 这需要某些网站的存
我正在开始使用 Heroku,并担心它是否会因我犯的错误而向我收费。例如,填充数据库超过 5MB。 那么,有没有办法为 Heroku 或通知系统设置计费限制,以便在我超过价格限制时发送通知? 先感谢您
如何更新我的 Heroku ,我的 Windows 终端显示以下内容: » Warning: heroku update available from 7.47.7 to 7.52.0. 请帮忙
我在免费的 Dyno 上运行基于 NodeJS 的应用程序,连接到 mongohq-MongoDB。我想迁移它以使用爱好 Dyno,这样做的动机不仅是避免 sleep 时间,而且是为了实现更高的 HT
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 9年前关闭。 Improve this q
如何将我的生产数据库拉到 heroku 上的暂存服务器? 我有两个 Remote ,production 和 staging。 来自documentation看来我想运行 heroku pg:copy
我有一个域example.com,我想将它用于位于example.herokuapp.com 的rails-app,我很困惑如何去做。 Heroku says "Zone apex domains (
我有一个 sinatra 应用程序,其中有一个 yml 文件来设置环境变量,我使用此方法调用它们 module MyConfig def config environment = ENV["RA
根据各种因素,一整天中,我的应用程序的负载可能会出现非常极端的增加。 那时,我想自动增加测功机的数量。 我想增加加载时间。因此,如果加载页面需要X倍的时间,请增加测功力。否则,请往下走。 这样的东西存
我想知道使用heroku工具栏在heroku帐户之间进行切换的最佳方法是什么。 我曾经有一个个人的heroku帐户,它是我所有职业性的heroku应用程序的协作者。问题是当我想进行一些对财务有影响的更
是否可以停止部署到当前正在构建的 Heroku ( git push heroku )? 类似 heroku run stopit! 顺便提一句。成功部署后回滚不是我想要的。 最佳答案 首先,安装He
我是一名优秀的程序员,十分优秀!