Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resque workers fail to run #48

Open
abscondment opened this issue Oct 17, 2013 · 1 comment
Open

Resque workers fail to run #48

abscondment opened this issue Oct 17, 2013 · 1 comment

Comments

@abscondment
Copy link

Let's look at the example from apn/tasks:

APN.password = ENV['CERT_PASS']
APN.full_certificate_path =  ENV['FULL_CERT_PATH']
APN.logger = Rails.logger

worker = ::Resque::Worker.new(APN::Jobs::QUEUE_NAME)

puts "*** Starting worker to send apple notifications in the background from #{worker}"
worker.work(ENV['INTERVAL'] || 5) # interval, will block

This starts just fine. However...

  • require 'apn/jobs/resque_notification_job' is now run inside the backend method.
  • The queue uses the job class APN::Jobs::ResqueNotificationJob.

So, since we've never called APN.backend in this worker (and we shouldn't have to do that!), the first queue item will crash when attempting to reference the un-loaded ResqueNotificationJob class.

I think the solution should load the job classes up front, rather than requiring a backend (which the workers won't even use) to be created.

How do you feel about trying to require both sidekiq and resque, like below?

begin
  require 'sidekiq'
  require 'apn/jobs/sidekiq_notification_job'
rescue LoadError
end

begin
  require 'resque'
  require 'apn/jobs/resque_notification_job'
rescue LoadError
end

This solves my problems, although it feels a little less than clean. If it's fine with you, I'll send a pull request.

@arthurnn
Copy link
Owner

Can you try latest master to see if solves the issue?

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants