开发者

Heroku: MongoHQ: connection problem

开发者 https://www.devze.com 2023-03-05 01:13 出处:网络
I recently forked https://github.com/fortuity/rails3-mongoid-omniauth and tried to get to run on heroku.com. This is an application which shows how to use MongoDB (via MongoHQ) on heroku, as well as O

I recently forked https://github.com/fortuity/rails3-mongoid-omniauth and tried to get to run on heroku.com. This is an application which shows how to use MongoDB (via MongoHQ) on heroku, as well as OAuth authentication. My forked code snapshot is at https://github.com/jgodse/rails3-mongoid-omniauth/tree/8cb490e660ab1d2d1df0f68312584563f0fd223a

After I tweaked mongoid.yml to include the URI parameter, remove other parameters for the production (i.e. heroku) environment and then started the application on heroku.com, I got the following log (from heroku logs).

←[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 f开发者_开发知识库rom /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

My heroku environment looks like this (with some key information xxxx'ed out):

$ 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

The heroku log says that it is still trying to connect to localhost:27017 even though I removed localhost references from mongoid.yml. Is there anything else I must do to force it to connect to my MONGOHQ_URL?


In the file mongoid.yml, I was supposed to use "MONGOHQ_URL", but I used "MONGHQ_URL". The code therefore behaved as it was supposed to and defaulted to localhost.

When I started using "MONGOHQ_URL" in mongoid.yml, everything worked fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号