Sas*_*sha 19 ruby-on-rails heroku resque redis
香港专业教育学院一直试图让resoku与heroku合作.我可以成功地让它在开发模式下工作,但是当我尝试推送到heroku时我得到了
Errno::ECONNREFUSED (Connection refused - Unable to connect to Redis on 127.0.0.1:6379):
Run Code Online (Sandbox Code Playgroud)
然后阅读并关注http://blog.redistogo.com/2010/07/26/resque-with-redis-to-go/
我把网站上列出的配置但出现以下错误
SocketError (getaddrinfo: nodename nor servname provided, or not known):
Run Code Online (Sandbox Code Playgroud)
我输入了我的初始化器/ resque.rb
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
ENV["redis://redistogo:11111111111111111@lab.redistogo.com:9254/"] ||= "redis://heroku_username:heroku_password@host:9254/"
uri = URI.parse(ENV["redis://redistogo:1111111111111111@lab.redistogo.com:9254/"])
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Run Code Online (Sandbox Code Playgroud)
但它会抛出上面提到的错误.在我的开发模式现在,我也得到了错误.
我尝试使用我的heroku用户名(即时通讯使用heroku中的add),将我的密码输入heroku,并将端口更改为9254.但是我现在不断收到套接字错误.我究竟做错了什么?
帮助将不胜感激.谢谢
UPDATE.
@kevin
我试过了
uri = URI.parse(ENV["my_url_string"] || "redis://localhost:9254/" )
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Run Code Online (Sandbox Code Playgroud)
在初始化程序/ redis.rb中,但我得到以下错误
Errno::ECONNREFUSED (Connection refused - Unable to connect to Redis on 127.0.0.1:6379):
Run Code Online (Sandbox Code Playgroud)
是错误中的数字,即127.0.0.1:6379显着?香港专业教育学院检查我的redis gui应用程序,并从heroku配置我的端口号是9254
REDISTOGO_URL => redis://redistogo:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@lab.redistogo.com:9254/
Run Code Online (Sandbox Code Playgroud)
你有其他配置设置吗?谢谢你的帮助!
最终更新.
我修好了它.我简直不敢相信!我的完整解决方案是
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Resque.redis = REDIS
Run Code Online (Sandbox Code Playgroud)
逐字.它没有明确设置网址,因为我猜heroku试图为我设置它
Kev*_*ell 40
对于我的设置,我有/config/initializers/redis.rb这些线:
uri = URI.parse(ENV["REDISTOGO_URL"] || "redis://localhost:6379/" )
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Run Code Online (Sandbox Code Playgroud)
我REDISTOGO_URL在我的Heroku的配置中定义.您应该能够通过键入以下内容来验证:
heroku config --app my_app
Run Code Online (Sandbox Code Playgroud)
你会在输出中看到的值 REDISTOGO_URL
您应该REDISTOGO_URL直接从Redis To Go 复制.您可以通过转到heroku中的实例并单击Add Ons - > Redis To Go来找到它.
这里有几个指针:
Sas*_*sha 15
我修好了它.我简直不敢相信!我的完整解决方案是
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Resque.redis = REDIS
Run Code Online (Sandbox Code Playgroud)
逐字.它没有明确设置网址,因为我猜heroku试图为我设置它
Fra*_*Jr. 11
我得到了同样的东西,所以,基本上Sidekiq没有从vars抓住REDISCLOUD_URL,它抓住了REDIS_PROVIDER.
heroku config:set REDIS_PROVIDER=REDISCLOUD_URL
Run Code Online (Sandbox Code Playgroud)
它就像一个魅力.
| 归档时间: |
|
| 查看次数: |
18333 次 |
| 最近记录: |