Scott
Scott

Reputation: 2258

using apn_sender on heroku

We built an api in rails and are hosting it on heroku and using apn_sender to do the push notifications. We got everything running locally with apn_sender but when we push it to heroku and run

heroku rake apn:sender

we get the following error "Connection refused - Unable to connect to Redis on 127.0.0.1:6379"

We added the redistogo addon.

UPDATE

We added a resque.rb initializer:

require 'resque'

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

and called to start up the worker

heroku rake environment apn:sender

and everything seemed to work.

Upvotes: 2

Views: 1770

Answers (1)

Scott
Scott

Reputation: 2258

Ok, so after further testing, the update I put in above doesn't work for very long before it crashes. We then followed this http://blog.redistogo.com/2010/07/26/resque-with-redis-to-go/

Changing

task "resque:setup" => :environment do
  ENV['QUEUE'] = '*'
end

to

task "apn:setup" => :environment do
  ENV['QUEUE'] = '*'
end

and

desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"

to

desc "Alias for apn:work (To run workers on Heroku)"
task "jobs:work" => "apn:work"

and it worked like a charm. Also note, that we had to add a worker dyno in heroku, which costs .05/hour or $35/month.

Upvotes: 2

Related Questions