Does Rake task need to run in the background using Resque?

依然范特西╮ 提交于 2019-12-25 16:41:49

问题


I have this code in my rake task. It seems overkill, since the rake task is already being run as a cron job. I think I can safely take it out of Resque and run it directly, but not sure if I missed something.

   desc "update daily sales"
    task :daily_sales => :environment do
      Resque.enqueue(DailySaleService.perform)
    end 

回答1:


Yes, it's overkill. There is no reason to use background processing for a rake task; you use background processing to remove heavy lifting from the HTTP request/response cycle to provide users with a better front-end experience. It won't provide any value in a rake task.



来源:https://stackoverflow.com/questions/22388155/does-rake-task-need-to-run-in-the-background-using-resque

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!