我一直试图让Resque(与Resque服务器)RedisToGo工作在Heroku(雪松)一段时间了,但我一直运行到这个错误:
Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)):
其本地的工作,我可以访问Redis的只是在Heroku的控制台罚款,我的应用程序。
我Procfile有:
web: bundle exec thin start -p $PORT -e $RACK_ENV
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
resque: env TERM_CHILD=1 RESQUE_TERM_TIMEOUT=10 bundle exec rake resque:work
我的Gemfile有:
gem 'redis'
#Background queue
gem 'resque', '~> 1.22.0', :require => "resque/server"
LIB /任务/ resque.rake:
require 'resque/tasks'
task "resque:setup" => :environment do
ENV['QUEUE'] = '*'
end
desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"
routes.rb中:
mount Resque::Server.new, :at => "/resque"
初始化:redis.rb:
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Resque.redis = REDIS
resque.rb;
Dir["#{Rails.root}/app/workers/*.rb"].each { |file| require file }
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
然后在我的应用程序/工人目录我有类似myjob.rb
我觉得我在圈子我要去这里,任何想法?