红宝石在轨道上 3 - 希罗库:MongoHQ:连接问题



我最近分叉了 https://github.com/fortuity/rails3-mongoid-omniauth,并试图在 heroku.com 上运行。这是一个应用程序,展示了如何在heroku上使用MongoDB(通过MongoHQ),以及OAuth身份验证。 我的分叉代码快照位于 https://github.com/jgodse/rails3-mongoid-omniauth/tree/8cb490e660ab1d2d1df0f68312584563f0fd223a

在我调整mongoid.yml以包含URI参数,删除生产(即heroku)环境的其他参数,然后在 heroku.com 上启动应用程序后,我得到了以下日志(来自heroku日志)。

←[36m2011-05-11T19:00:36+00:00 heroku[web.1]:←[0m Starting process with command: thin -p 41913 -e production -R /home/heroku_rack/heroku.ru start
←[36m2011-05-11T19:00:42+00:00 app[web.1]:←[0m /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.0/lib/mongo/connection.rb:494:in connect': Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)
←[36m2011-05-11T19:00:42+00:00 app[web.1]:←[0m from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.0/lib/mongo/connection.rb:632:insetup'
←[36m2011-05-11T19:00:42+00:00 app[web.1]:←[0m from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.0/lib/mongo/connection.rb:101:in initialize'
←[36m2011-05-11T19:00:42+00:00 app[web.1]:←[0m from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.0/lib/mongo/connection.rb:152:innew'
←[36m2011-05-11T19:00:42+00:00 app[web.1]:←[0m from /app/.bundle/gems/ruby/1.9.1/gems/mongo-1.3.0/lib/mongo/connection.rb:152:in from_uri'
←[36m2011-05-11T19:00:42+00:00 app[web.1]:←[0m from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.1/lib/mongoid/config/database.rb:86:inmaster'
←[36m2011-05-11T19:00:42+00:00 app[web.1]:←[0m from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.1/lib/mongoid/config/database.rb:19:in configure'
←[36m2011-05-11T19:00:42+00:00 app[web.1]:←[0m from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.1/lib/mongoid/config.rb:319:inconfigure_databases'
←[36m2011-05-11T19:00:42+00:00 app[web.1]:←[0m from /app/.bundle/gems/ruby/1.9.1/gems/mongoid-2.0.1/lib/mongoid/config.rb:114:in from_hash'
←[36m2011-05-11T19:00:42+00:00 app[web.1]:←[0m from (eval):2:infrom_hash'
←[36m2011-05-11T19:00:42+00:00 heroku[web.1]:←[0m Process exited
←[36m2011-05-11T12:00:43-07:00 heroku[web.1]:←[0m State changed from starting to crashed

我的 heroku 环境看起来像这样(有一些关键信息 xxxx's 出来):

$ heroku info
=== jgodse-omniauth-mongoid
Web URL: http://jgodse-omniauth-mongoid.heroku.com/
Git Repo: git@heroku.com:jgodse-omniauth-mongoid.git
Dynos: 1
Workers: 0
Repo size: 5M
Slug size: 5M
Stack: bamboo-mri-1.9.2
Data size: (empty)
Addons: Basic Logging, MongoHQ MongoHQ Free, Shared Database 5MB
Owner: xxxxxxxx
Jay@JAY-PC ~/rapps/rails3-mongoid-omniauth (master)
$ heroku config --long
BUNDLE_WITHOUT => development:test
DATABASE_URL => postgres://xxxxxxxxxxxx
LANG => en_US.UTF-8
MONGOHQ_URL =>    mongodb://heroku:xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mongohq.com:27098/app527030
RACK_ENV => production
SHARED_DATABASE_URL => postgres://xxxxxxx xxxxxx

heroku日志说它仍在尝试连接到localhost:27017,即使我从mongoid.yml中删除了localhost引用。我还必须执行其他操作才能强制它连接到我的MONGOHQ_URL吗?

在文件mongoid.yml中,我应该使用"MONGOHQ_URL",但我使用了"MONGHQ_URL"。因此,代码的行为符合预期,并默认为 localhost。

当我开始在mongoid.yml中使用"MONGOHQ_URL"时,一切正常。

相关内容

  • 没有找到相关文章