[英]How do I programmatically update the Resque schedule?
So I'm looking into adding some functionality in my app which will allow users to schedule certain tasks. 因此,我正在研究在我的应用程序中添加一些功能,这些功能将允许用户安排某些任务。 A brief search brought Resque and Resque-Scheduler to my attention.
简短的搜索使我注意到了Resque和Resque-Scheduler。 However, I'm wondering if it will let me change scheduled tasks on the fly.
但是,我想知道是否能让我即时更改预定的任务。 From what I've seen, the scheduler only loads from a config file.
据我了解,调度程序仅从配置文件加载。 Is there some way to make this work, or am I pursuing the wrong track?
有什么方法可以使这项工作奏效,还是我走错了路?
Not really config
is not the only way to schedule a task in resque
using resque-scheduler
不是真正的
config
不是使用resque-scheduler
在resque
安排任务的唯一方法
config
is generally used for recurring task something like cron-tab
do in your case config
通常用于重复执行任务,例如cron-tab
but in your case it wont work here how you can programmatically schedule your task using resque-scheduler 但是在您的情况下,它在这里行不通,如何使用resque-scheduler以编程方式计划任务
Resque.enqueue_in(5.days, SomeJob) # run a job in 5 days
or 要么
Resque.enqueue_at(5.days.from_now, SomeJob) # run SomeJob at a specific time
You can also remove them if you want 您也可以根据需要删除它们
Resque.remove_delayed
You can find completed guide of it in resque-scheduler README 您可以在resque-scheduler README中找到它的完整指南。
Hope this help 希望这个帮助
You can change the schedule dynamically. 您可以动态更改时间表。
From the repo readme ( https://github.com/resque/resque-scheduler ) 从回购自述文件( https://github.com/resque/resque-scheduler )
Dynamic schedules allow for greater flexibility than static schedules as they can be set, unset or changed without having to restart resque-scheduler.
动态计划比静态计划具有更大的灵活性,因为可以设置,取消设置或更改动态计划,而无需重新启动resque-scheduler。 You can specify, if the schedule must survive a resque-scheduler restart or not.
您可以指定计划是否必须在resque-scheduler重新启动后继续存在。
[Note that at the time of this writing, the approach of setting "Resque:Scheduler.dynamic = true" in your Rakefile is not working. [请注意,在撰写本文时,在Rakefile中设置“ Resque:Scheduler.dynamic = true”的方法不起作用。 Instead, use the option of setting an env variable (DYNAMIC_SCHEDULE)]
而是使用设置环境变量的选项(DYNAMIC_SCHEDULE)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.