当前最好的 Rails 后台任务方法? [英] Best current rails background task method?

查看:35
本文介绍了当前最好的 Rails 后台任务方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找出在后台运行脚本的最佳方式.我一直在环顾四周,发现了很多选择,但在过去几年中,许多/大多数似乎都变得不活跃了.让我描述一下我的需求.

I am trying to find out the best way to run scripts in the background. I have been looking around and found plenty of options, but many/most seem to have become inactive in the past few years. Let me describe my needs.

rails 应用程序基本上是一个前端,用于配置这些脚本的运行时间和方式.脚本运行并生成报告并发送电子邮件警报.因此,用户必须能够配置开始时间以及这些脚本动态运行的频率.脚本本身应该可以访问 rails 环境,以便将生成的报告保存在数据库中.

The rails app is basically a front-end to configure when and how these scripts will be run. The scripts run and generate reports and send email alerts. So the user must be able to configure the start times and how often these scripts will run dynamically. The scripts themselves should have access to the rails environment in order to save the resulting reports in the DB.

只是想从无数的选择中找出最好的方法.

Just trying to figure out the best method from the myriad of options.

推荐答案

我认为您正在寻找后台作业排队系统.

I think you're looking for a background job queuing system.

为此,您正在寻找 resquedelayed_job.两者都支持未来某个时间点的调度任务——delay_job 本身就是这样做的,而 resque 有一个名为 resque_scheduler 的插件.

For that, you're either looking for resque or delayed_job. Both support scheduling tasks at some point in the future -- delayed_job does this natively, whereas resque has a plugin for it called resque_scheduler.

您可以使用您指定的参数在后台将作业排入队列,然后在您选择的时间执行它们.您可以将作业设置为无限期或固定次数重复(至少使用 resque-scheduler,不确定 delay_job).

You would enqueue jobs in the background with parameters that you specify, and then at the time you selected they'll be executed. You can set jobs to recur indefinitely or a fixed number of times (at least with resque-scheduler, not sure about delayed_job).

delayed_job 更容易设置,因为它将所有内容保存在数据库中.resque 更健壮,但要求您在堆栈中安装 redis -- 但如果您已经这样做了,它几乎是解决您问题的理想解决方案.

delayed_job is easier to set up since it saves everything in the database. resque is more robust but requires you to have redis in your stack -- but if you do already it's pretty much the ideal solution for your problem.

这篇关于当前最好的 Rails 后台任务方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆