Rails delayed job not working

前端 未结 2 757
夕颜
夕颜 2020-12-21 19:44

My delayed job is not working. I am trying to create an background task for a rake file using a delayed job that should run every 15 minute. I have copied my rake tasks in m

2条回答
  •  萌比男神i
    2020-12-21 20:42

    If you just want to run code every X minute/hour, than you don't need delayed_job for that. That would be kind of overkill and over engineered. Just use this code here:

        until 2 < 1 do 
            if Time.now.min % 15 == 0
    
                puts "Execute your code here!"
    
                if Time.now.min % 15 == 0
                    sleep(60)
                end
            end
        end
    

    Put the code into Rakefile, make a task out of it and deploy it on a heroku worker dyno. That will work. Here is a complete tutorial for that: http://robert-reiz.com/2012/06/12/cron-jobs-on-heroku/.

    For that solution you even don't need Herokus Cron or Scheduler Add-On. And you don't need any additional GEMs like delayed_job. Pragmatic solution. Keep it slim ;-)

提交回复
热议问题