我正在尝试使用 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
任何帮助,将不胜感激!