resque-scheduler icon indicating copy to clipboard operation
resque-scheduler copied to clipboard

Persisted Dynamically created job prevents scheduler from starting

Open dwillie opened this issue 9 years ago • 3 comments

I created a repeating job dynamically, which worked well. The job started after the given first_at time and everything was peachy. The job was persisted, as I wanted it to continue its looping if the server was stopped and started again later.

When starting up the rake resque:scheduler command at a later date I was presented with ArgumentError: cannot set first[_at|_in] in the past: -454.02 -> 2015-07-27 15:50:15 +1000 Which was not what I was expecting.

My goal is to have repeating tasks represented as a model within my rails app, which can be created and destroyed as resources. Eg. I have a ScheduledTask model which, when created, dynamically creates a persisted repeating task. When it is destroyed, it destroys this task. In the meantime, any time the scheduler is up and running, the task should be performed at the requested interval assuming the first_at/_in time has passed.

Any advice would be greatly appreciated! If you think there is perhaps a more appropriate approach available than the one I am using I'd love to hear it. I wasn't sure of the issue etiquette here so if this post is inappropriate let me know and I can move this elsewhere.

Thanks in advance!

dwillie avatar Jul 27 '15 07:07 dwillie

Pretty much this is just be delegated to Rufus, which is hating on the stuff in the past. I believe right now this should just be considered broken and unusable. The only alternative would be not using the first_ option or using the CRON syntax.

A ScheduledJob would be a good approach and could dynamically generate the first_at. Probably also supporting the additional rufus-scheduler options would be nice.

carsonreinke avatar May 13 '16 16:05 carsonreinke

I'm using resque-schedule 4.1.0 and rufu-schedule 1.3.0. And dynamic-scheduler works well. Try to change resque-schedule and rufu-schedule's version.

yihoyoung avatar Aug 22 '16 04:08 yihoyoung

Was this issue resolved? I am facing something similar with dynamic scheduled jobs. Using the latest version of resque-scheduler and rufus-scheduler.

nishantnasa avatar Feb 09 '17 07:02 nishantnasa