在heroku上使用apn_sender

发布于 2024-11-19 11:39:25 字数 591 浏览 2 评论 0原文

我们在 Rails 中构建了一个 api,并将其托管在 heroku 上,并使用 apn_sender 来执行推送通知。我们使用 apn_sender 在本地运行所有内容,但是当我们将其推送到 heroku 并运行时,

heroku rake apn:sender

我们收到以下错误“连接被拒绝 - 无法连接到 127.0.0.1:6379 上的 Redis”

我们添加了 redistogo 插件。

更新

我们添加了一个 resque.rb 初始值设定项:

require 'resque'

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

并调用来启动工作程序

heroku rake environment apn:sender

,一切似乎都正常。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜血缘 2024-11-26 11:39:25

好的,经过进一步测试,我上面放入的更新在崩溃之前不会工作很长时间。然后我们按照这个http://blog.redistogo。 com/2010/07/26/resque-with-redis-to-go/

更改

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

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

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

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

,它就像一个魅力。另请注意,我们必须在 Heroku 中添加一个 Worker dyno,其成本为 0.05/小时或 35 美元/月。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文