如何让Redis在Heroku上开始? [英] How to get Redis to start on Heroku?

查看:118
本文介绍了如何让Redis在Heroku上开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Heroku上添加了 Redistogo nano加载项,并且我已经在控制台中成功测试了它。但是,当我的应用程序尝试与Redis连接时,出现以下错误:



Heroku日志文件:

<$ p $ Errno :: ECONNREFUSED(连接被拒绝 - 无法连接到127.0.0.1:6379上的Redis):$ {code> 2011-10-12T08:19:50 + 00:00 app [web.1] b $ b 2011-10-12T08:19:50 + 00:00 app [web.1]:app / controllers / sessions_controller.rb:14:在`create'
pre>

为什么要在本地主机上访问Redis?



配置/初始化程序中的Redis.rb文件夹中有这个,这几乎肯定是问题。

 #下面粘贴的内容是逐字粘贴的。我不知道该怎么改变值。 

uri = URI.parse(ENV [REDISTOGO_URL])
REDIS = Redis.new(:host => uri.host,:port => uri.port,:密码=> uri.password)


解决方案

Resque?如果是这样,您需要告诉Resque使用哪个Redis。

  Resque.redis = REDIS 

code>

如果没有,那么您发布的代码不会设置您的REDIS连接。


I've added the Redistogo nano add-on on Heroku and I've tested it out in the console successfully. However when my app tries to connect with Redis I get the following error:

Heroku Log file:

2011-10-12T08:19:50+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - Unable to connect to Redis on 127.0.0.1:6379):
2011-10-12T08:19:50+00:00 app[web.1]:   app/controllers/sessions_controller.rb:14:in `create'

Why is it trying to access Redis on localhost?

My Redis.rb in the config/initializers folder has this, which is almost certainly the problem.

#What's pasted below is pasted ad verbatim. I don't know what to change the values to.

uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)

解决方案

Are you using Resque? If so, you'll need to tell Resque which Redis to use.

Resque.redis = REDIS

If not, then the code you've posted about is NOT setting your REDIS connection up.

这篇关于如何让Redis在Heroku上开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆