我有一个简单的问题。我也很喜欢rails和heroku。我最近从以下git存储库git://github.com/barmstrong/ribbot.git下载了一个开源代码。我正在使用mongo db运行rails并且已经设置了环境。决定使用heroku作为我的服务器解决方案我已经下载了mongoLAB上的添加但是当我尝试运行代码时出现以下错误。然而,我可以在我的本地机器上顺利运行它。
2012-04-16T22:51:04+00:00 heroku[api]: Add-on add mongolab:starter by *******@hotmail.com
2012-04-16T22:51:04+00:00 heroku[api]: Release v2 created by *******@hotmail.com
2012-04-16T22:51:21+00:00 heroku[slugc]: Slug compilation started
2012-04-16T22:53:20+00:00 heroku[api]: Add-on add shared-database:5mb by *******@hotmail.com
2012-04-16T22:53:20+00:00 heroku[api]: Release v3 created by *******@hotmail.com
2012-04-16T22:53:21+00:00 heroku[api]: Config add RAILS_ENV, LANG, PATH, RACK_ENV, GEM_PATH by *******@hotmail.com
2012-04-16T22:53:21+00:00 heroku[api]: Release v4 created by *******@hotmail.com
2012-04-16T22:53:21+00:00 heroku[api]: Release v5 created by *******@hotmail.com
2012-04-16T22:53:21+00:00 heroku[api]: Deploy fe1b768 by *******@hotmail.com
2012-04-16T22:53:21+00:00 heroku[web.1]: State changed from created to starting
2012-04-16T22:53:22+00:00 heroku[slugc]: Slug compilation finished
2012-04-16T22:53:34+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 44817`
2012-04-16T22:54:06+00:00 app[web.1]: [2012-04-16 22:54:06] INFO WEBrick 1.3.1
2012-04-16T22:54:06+00:00 app[web.1]: [2012-04-16 22:54:06] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2012-04-16T22:54:06+00:00 app[web.1]: [2012-04-16 22:54:06] INFO WEBrick::HTTPServer#start: pid=1 port=44817
2012-04-16T22:54:08+00:00 heroku[web.1]: State changed from starting to up
2012-04-16T22:54:57+00:00 app[web.1]: => Booting WEBrick
2012-04-16T22:54:57+00:00 app[web.1]: => Rails 3.1.1 application starting in production on http://0.0.0.0:44817
2012-04-16T22:54:57+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-04-16T22:54:57+00:00 app[web.1]: localhost:11211 failed (count: 0)
2012-04-16T22:54:57+00:00 app[web.1]:
2012-04-16T22:54:57+00:00 app[web.1]:
2012-04-16T22:54:57+00:00 app[web.1]: Started GET "/" for 208.124.140.154 at 2012-04-16 22:54:57 +0000
2012-04-16T22:54:58+00:00 app[web.1]: cache: [GET /] miss
2012-04-16T22:54:58+00:00 app[web.1]: Processing by PostsController#index as HTML
2012-04-16T22:54:58+00:00 app[web.1]: Redirected to http://herokuapp.com/forums
2012-04-16T22:54:58+00:00 app[web.1]: Completed 302 Found in 114ms
2012-04-16T22:54:58+00:00 heroku[router]: GET impact-project.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=885ms status=302 bytes=93
2012-04-16T22:55:14+00:00 app[web.1]: localhost:11211 failed (count: 1)
2012-04-16T22:55:14+00:00 app[web.1]: localhost:11211 is down
2012-04-16T22:55:14+00:00 app[web.1]:
2012-04-16T22:55:14+00:00 app[web.1]:
2012-04-16T22:55:14+00:00 app[web.1]: Started GET "/" for 208.124.140.154 at 2012-04-16 22:55:14 +0000
2012-04-16T22:55:14+00:00 app[web.1]: cache: [GET /] miss
2012-04-16T22:55:14+00:00 app[web.1]: Processing by PostsController#index as HTML
2012-04-16T22:55:14+00:00 app[web.1]: Redirected to http://herokuapp.com/forums
2012-04-16T22:55:14+00:00 app[web.1]: Completed 302 Found in 11ms
2012-04-16T22:55:14+00:00 heroku[router]: GET impact-project.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=528ms status=302 bytes=93
2012-04-16T22:55:57+00:00 app[web.1]: localhost:11211 failed (count: 2)
2012-04-16T22:55:57+00:00 app[web.1]:
2012-04-16T22:55:57+00:00 app[web.1]:
2012-04-16T22:55:57+00:00 app[web.1]: Started GET "/" for 208.124.140.154 at 2012-04-16 22:55:57 +0000
2012-04-16T22:55:57+00:00 app[web.1]: cache: [GET /] miss
2012-04-16T22:55:57+00:00 app[web.1]: Processing by PostsController#index as HTML
2012-04-16T22:55:57+00:00 app[web.1]: Redirected to http://herokuapp.com/forums
2012-04-16T22:55:57+00:00 app[web.1]: Completed 302 Found in 4ms
2012-04-16T22:55:57+00:00 heroku[router]: GET impact-project.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=549ms status=302 bytes=93
答案 0 :(得分:1)
我怀疑您在Mongo驱动程序配置中的某处已经localhost:11211
进行了硬编码,或者未指定使用环境中的MONGOLAB_URI
值。
请参阅此处了解MongoLab附加文档:https://devcenter.heroku.com/articles/mongolab有关使用环境变量值的部分,请参阅:https://devcenter.heroku.com/articles/mongolab#connecting_your_heroku_application_to_your_mongodb_database并且是特定于驱动程序的。
希望有所帮助。