Created
May 15, 2019 11:26
-
-
Save wintersolutions/689588ecc2caaf36809ed6c6ffb028f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Resume rufus-scheduler (v3.6) jobs once after pause/resume: | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment