Is it possible to start resque-web listening to a redis socket?
I have disable开发者_如何学JAVAd redis listening to port 6379 and enabled the websocket. It works wonderfully from my application, but when I launch resque-web it keeps listening trough network interface and fails with message:
Can't connect to Redis! (redis://127.0.0.1:6379/0)
Someone knows if it's possible to make resque-web use the socket instead of the network?
Thanks in advance
I've been reading resque-web's code and I realized that it internally loads any path you provide as parameter to the command. So I have created a plain ruby script that connects to Redis with redis gem and then assigns this instance to Resque.redis:
Just created a file called 'resque-web-hack.rb':
require 'redis'
require 'resque'
$redis = Redis.new(:path => '/tmp/redis.sock')
Resque.redis = $redis
And then used it like this:
$ resque-web /path/to/my/file/resque-web-hack.rb
It's just a hack, but it works for me by now...
I just fixed same problem :) So here is the solution
In my ./config/resque.yml I have this line
development: /tmp/redis.sock
This is my RAILS_ROOT/config/initializers/resque.rb
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
rails_env = ENV['RAILS_ENV'] || 'development'
resque_config = YAML.load_file(rails_root + '/config/resque.yml')
if resque_config[rails_env] =~ /^\// # using unix socket
Resque.redis = Redis.new(:path => resque_config[rails_env])
else
Resque.redis = resque_config[rails_env]
end
精彩评论