I've been trying to get Resque (with Resque server) & RedisToGo working on heroku (cedar) for awhile now, but I keep running into this error:
Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)):
Its working locally, and I can access redis just fine in Heroku's console for my app.
My Procfile has:
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
My Gemfile has:
gem 'redis'
#Background queue
gem 'resque', '~> 1.22.0', :require => "resque/server"
lib/tasks/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"
initializers: 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 }
then in my app/workers directory I have something like myjob.rb
I feel like I'm going in circles here, any ideas?
heroku config
and ensure you have an entry for REDISTOGO_URL – Ocieock