0

我是新来的铁路。我想将一个简单的 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方面有什么改变吗?谢谢

4

1 回答 1

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/

于 2012-08-21T19:20:15.563 回答