开发者

Rails how to create a delayed job for a rake taks?

开发者 https://www.devze.com 2023-02-24 06:17 出处:网络
How do I crea开发者_运维技巧te a delayed job for a rake task that should run every 15 minutes?You can give it a try: https://github.com/defunkt/resqueI am using Resque + Redis with Heroku. Delayed job

How do I crea开发者_运维技巧te a delayed job for a rake task that should run every 15 minutes?


You can give it a try: https://github.com/defunkt/resque


I am using Resque + Redis with Heroku. Delayed job is also very much supported on their cloud service.

In lib/tasks/cron.rb

desc "This task is called by the Heroku cron add-on"
task :cron => :environment do

  def resubmit_pending_jobs
    Resque.enqueue(SomeJob, job.id)
  end
end

One way I can think of is by using the cron addon offered by Heroku which does it every hour (not 15 mins). Perhaps the above code block can assist you in finding a similar implementation for Delayed Job.

In the case you are interested in getting Resque setup with RedisToGo and Heroku, please consult this guide.

Hope that helps!


Take a look at SimpleWorker. It's a cloud-based background processing / worker queue for Ruby apps. It's an add-on for Heroku.

You create worker classes in your code and the queue up jobs to run right away or run later -- one time or on a recurring schedule.

  worker = SomeWorker.new
  # Set attributes for worker to use here
  worker.schedule(:start_at => 1.minute, :run_every => 900)
0

精彩评论

暂无评论...
验证码 换一张
取 消