简体   繁体   中英

apn_sender failing to start resque worker for Apple Push Notifications

I am trying to use the apn_sender gem to send Apple Push Notifications. I have followed the instructions at the github page as well as here .

My redis worker starts successfully, and I am (seemingly) able to successfully start a resque worker (and verify its running with the list command) having followed this with this command:

resque:work QUEUE='*'

However, when I try to start the app_sender with

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

I get the following error:

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>'

And, my script/apn_sender looks like:

#!/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

Any help would be appreciated!

I am pretty much sure the issue in here is the version of resque. I will double check, but as far as I tested apn_sender works with resque 1.19.0 and nothing over that. The reason in here is some monkey patches on resque gem. After double checking the correct version of resque I will push a update to the gemspec file so nobody will get this anymore. Also in version 2.0(master) we are not monkey patching resque anymore, and wont even be a forced dependency.

Short fix for you, force the resque version to use 1.19.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM