Hi I have a question regarding rufus-scheduler v3.6 pause/resume. I initialize a job with
Rufus::Scheduler.singleton.every '5s', callable when I do a
Rufus::Scheduler.singleton.pause the job gets paused as expected, when I do a
Rufus::Scheduler.singleton.resume ~20 seconds afterwards the job is run 5 times. I assume this is expected behaviour. But is there a easy way to "ingore" the executions that should've happened during the pause period? I.e. resume and run the job only once?
In case somebody needs the resume functionality in the future, this is what im going with now:
def self.scheduler Rufus::Scheduler.singleton end def self.resume scheduler.resume # to change the paused? status scheduler.jobs.each do |job| paused_duration = EtOrbi.now - job.paused_at resume_at = paused_duration >= job.frequency ? EtOrbi.now : EtOrbi.now + (job.frequency - paused_duration) job.next_time = resume_at job.resume end end def self.pause scheduler.pause # to change the paused? status scheduler.jobs.each(&:pause) # pause each job so job.paused_at is set end
discard_past:is on by default for rufus-scheduler >= 3.0