2

我正在尝试使用 apn_sender gem 发送 Apple 推送通知。我已按照 github 页面和此处的说明进行操作。

我的 redis 工作程序成功启动,并且我(似乎)能够成功启动一个 resque 工作程序(并使用 list 命令验证其运行),并使用以下命令执行操作:

resque:work QUEUE='*'

但是,当我尝试启动 app_sender 时

script/apn_sender --environment=production --verbose start

我收到以下错误:

I, [2013-06-03T16:14:17.848632 #15074]  INFO -- : 2013-06-03 16:14:17 -0400: Running before_first_fork hook
I, [2013-06-03T16:14:17.848968 #15074]  INFO -- : 2013-06-03 16:14:17 -0400: Failed to start worker : #<NoMethodError: undefined method `call' for []:Array>
F, [2013-06-03T16:14:17.849138 #15074] FATAL -- : wrong number of arguments (1 for 0) (ArgumentError)
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/apn_sender-1.0.5/lib/resque/hooks/before_unregister_worker.rb:10:in `unregister_worker'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/resque-1.24.1/lib/resque/worker.rb:176:in `rescue in work'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/resque-1.24.1/lib/resque/worker.rb:130:in `work'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/apn_sender-1.0.5/lib/apn/sender_daemon.rb:70:in `run'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/apn_sender-1.0.5/lib/apn/sender_daemon.rb:58:in `block (2 levels) in daemonize'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons/application.rb:255:in `call'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons/application.rb:255:in `block in start_proc'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons/daemonize.rb:82:in `call'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons/daemonize.rb:82:in `call_as_daemon'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons/application.rb:259:in `start_proc'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons/application.rb:296:in `start'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons/controller.rb:70:in `run'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons.rb:197:in `block in run_proc'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `call'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `catch_exceptions'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/daemons-1.1.9/lib/daemons.rb:196:in `run_proc'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/apn_sender-1.0.5/lib/apn/sender_daemon.rb:57:in `block in daemonize'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/apn_sender-1.0.5/lib/apn/sender_daemon.rb:55:in `times'
/Users/.../.rvm/gems/ruby-1.9.3-p327/gems/apn_sender-1.0.5/lib/apn/sender_daemon.rb:55:in `daemonize'
script/apn_sender:10:in `<main>'

而且,我的脚本/apn_sender 看起来像:

#!/usr/bin/env ruby

# Daemons sets pwd to /, so we have to explicitly set RAILS_ROOT
RAILS_ROOT =File.expand_path(File.join(File.dirname(__FILE__),'..'))

require 'rubygems'
require 'apn'
require 'apn/sender_daemon'

APN::SenderDaemon.new(ARGV).daemonize

任何帮助,将不胜感激!

4

1 回答 1

1

我很确定这里的问题是 resque 的版本。我会仔细检查,但据我测试 apn_sender 与 resque 1.19.0 一起工作,仅此而已。这里的原因是 resque gem 上的一些猴子补丁。在仔细检查了 resque 的正确版本后,我将更新 gemspec 文件,这样就没有人会再得到它了。同样在 2.0(master) 版本中,我们不再是猴子修补 resque,甚至不会是强制依赖。

为您提供简短修复,强制 resque 版本使用 1.19.0。

于 2013-06-04T13:36:04.967 回答