Pergunta

I am using this plugin for scheduled job.But it is not working. I am confused about some points,Should I need to create the Job class and set their name in to schedule file?When testing it then,Should I run the rescue scheduler and Resque worker both or only one of them.

Thanks in advance.

Foi útil?

Solução

My Resque Scheduler config... you will mostly need all these pieces:

YML file (config/resque_scheduler.yml):

every_1_minute:
  cron: "* * * * *"
  class: EveryMinute
  queue: some_queue
  description: Tasks to perform every minute

config/initializers/resque.rb:

require 'resque_scheduler'
Resque.schedule = YAML.load_file(File.join(Rails.root, 'config/resque_scheduler.yml'))

Ruby class (lib/every_minute.rb or somewhere in the load path):

class EveryMinute
  def self.perform
    puts "Hello every minute!"
  end
end

You need to run

rake resque:scheduler
rake resque:work

The resque:scheduler process periodically queues up jobs, hence the scheduling. And the workers will just do the jobs blindly. This is why you need BOTH to successfully schedule and run jobs periodically.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top