Mongo连接失败

时间:2012-08-21 16:15:41

标签: ruby-on-rails-3 cloudfoundry

我是铁杆新手。我想将一个简单的rails应用程序推送到cloudfoundry,我收到一个错误:

 ====> /logs/stderr.log <====
/var/vcap/data/dea/apps/mytestapp-0
-4a068e3fd2b22422bdd29f3762e9bc9b/app/rubygems/ruby/1.9.1/gems/mongo-
1.6.4/lib/mongo/connection.rb:420:in `connect': Fail:27017  (Mongo::ConnectionFailure)

示例应用程序gemfile:

source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'mongo_mapper'
gem 'bson_ext'

mongo.yml:

defaults: &defaults
host: 127.0.0.1
port: 27017

development:
<<: *defaults 
database: cloud_foundry_rails_tutorial_development

test:
<<: *defaults
database: cloud_foundry_rails_tutorial_test

# set these environment variables on your prod server
production: 
host: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-2.0'].first['credentials']['hostname']  
rescue 'localhost' %>

port: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-2.0'].first['credentials']['port']    
rescue '27017' %>

database: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-2.0'].first['credentials']['db'] 
rescue 'cloud_foundry_rails_tutorial' %>

username: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-2.0'].first['credentials']['username'] 
rescue '' %>

password: <%= JSON.parse( ENV['VCAP_SERVICES'] )['mongodb-2.0'].first['credentials']['password'] 
rescue '' %>

我上周没有任何问题就推送到CF但是现在它不起作用了? CF方面有什么变化吗? 感谢

1 个答案:

答案 0 :(得分:1)

CloudFoundry.com上周从MongoDB 1.8升级到2.0,这可能会影响你的应用。我将与CF.com工程团队核实并在必要时提交错误。

但是,由于您在mongo.yml中手动指定了连接信息,您是否禁用了服务的自动配置?为此,请创建文件config/cloudfoundry.yml并添加:

autoconfig: false

有关Ruby应用程序中服务自动配置的更多信息,请参阅http://blog.cloudfoundry.com/2012/03/12/using-cloud-foundry-services-with-ruby-part-1-auto-reconfiguration/

相关问题