简体   繁体   中英

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. 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 is generally used for recurring task something like cron-tab do in your case

but in your case it wont work here how you can programmatically schedule your task using 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

Hope this help

You can change the schedule dynamically.

From the repo readme ( 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. You can specify, if the schedule must survive a resque-scheduler restart or not.

[Note that at the time of this writing, the approach of setting "Resque:Scheduler.dynamic = true" in your Rakefile is not working. Instead, use the option of setting an env variable (DYNAMIC_SCHEDULE)]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM