문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top