Ruby-on-rails – Resque workers failing silently with no logs or no debug information

redisresqueruby-on-railsruby-on-rails-3

I have a piece of code code which runs some method and I have put that method inside the self.perform as below

class StartWorker
@queue = :worker

 def self.perform
 puts "hello"
  Parser.find_all_by_class_name("Parser").first.sites.each do |s|
   site = Site.find(s.id)
   parser = Parser.new(site)
   parser.run
     end
     end
     end

If I comment the def self.perform and end of this and run the file it is correctly showing the desired results but when I try to put this as a background task by uncommenting the same It is failing silently into the resque panel showing nothing .and also with no outputs in the command prompt

I am queuing this from resque-scheduler, inside my resque_schedule.yml

start_worker:
cron: "55 6 * * *"
class: StartWorker
queue: worker
args:
description: "This job starts all the worker jobs"

I tried putting some simple puts statements inside the the def self.perform method to check whether the control is passing inside the method or not but it seems the control is not even passing inside the self.perform method

also I tried to load the rails environment and required resque inside it but of no use
I have runned the bundle exec rake resque:work QUEUE='*' script for all the above before making any changes

I tried Resque.info inside the rails console it is showing like this ,

 {:working=>0, :queues=>1, :failed=>1, :environment=>"development", :servers=>["redis://localhost:6379/0"], :pending=>0, :processed=>1, :workers=>1}

Any Ideas how to overcome this?

Best Answer

  1. Have you checked the resque-web panel to see what that failed job is?
  2. Make sure you restart workers after any changes.
  3. If you're not seeing 'hello' in your logs anywhere (specifically log/worker.log or where ever yours log to) then the function simply isn't happening.
  4. bundle exec rake resque:work QUEUE='*' should be bundle exec rake resque:work QUEUE=* , just incase you really did quote the wildcard.
Related Topic