Rake 任务是否需要使用 Resque 在后台运行? [英] Does Rake task need to run in the background using Resque?
本文介绍了Rake 任务是否需要使用 Resque 在后台运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的 rake 任务中有这个代码.这似乎有点矫枉过正,因为 rake 任务已经作为 cron 作业运行了.我想我可以安全地将它从 Resque 中取出并直接运行它,但不确定我是否遗漏了什么.
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
推荐答案
是的,这太过分了.没有理由为 rake 任务使用后台处理;您可以使用后台处理从 HTTP 请求/响应周期中移除繁重的工作,从而为用户提供更好的前端体验.它不会在 rake 任务中提供任何价值.
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.
这篇关于Rake 任务是否需要使用 Resque 在后台运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文