Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 12:34
    gr8bit commented #50
  • 12:28
    gr8bit commented #50
  • 12:15
    jmettraux commented #50
  • 12:06
    gr8bit commented #50
  • 11:31
    gr8bit commented #50
  • Dec 02 23:07
    jmettraux commented #50
  • Dec 02 20:37
    gr8bit commented #50
  • Dec 02 20:36
    gr8bit commented #50
  • Dec 02 01:28
    jmettraux commented #50
  • Dec 02 01:25
    gr8bit commented #50
  • Dec 02 01:18
    gr8bit commented #50
  • Dec 02 01:12
    jmettraux commented #50
  • Dec 02 01:12
    jmettraux commented #50
  • Dec 02 01:11
    jmettraux commented #50
  • Dec 02 01:10
    gr8bit commented #50
  • Dec 02 01:06
    jmettraux commented #50
  • Dec 02 01:06
    gr8bit commented #50
  • Dec 02 01:00
    gr8bit commented #50
  • Dec 02 00:49
    jmettraux commented #50
  • Dec 02 00:47
    jmettraux closed #50
John Mettraux
@jmettraux
Welcome to the chat room dedicated to fugit, et-orbi, and rufus-scheduler
John Mettraux
@jmettraux
Wrote about the latest rufus-scheduler and fugit releases http://jmettraux.skepti.ch/20190422.html?t=rufus_scheduler_3_6_0_released&f=gtr
wintersolutions
@wintersolutions

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?

Thanks!

John Mettraux
@jmettraux
@wintersolutions hello
wintersolutions
@wintersolutions
Hi
jmettraux @jmettraux looking at the documentation...
John Mettraux
@jmettraux
unfortunately, there are no easy ways (out of the box) ways to do that
if you need too, I can add an option to Job#resume to prevent/ignore
wintersolutions
@wintersolutions
Probably I'm the only person that needs this feature and I think I can work around it in other ways
John Mettraux
@jmettraux
ok
wintersolutions
@wintersolutions
Thanks for your time and help and for creating a amazing gem ;)
John Mettraux
@jmettraux
ah, you're welcome!
John Mettraux
@jmettraux
@wintersolutions one question: what version of rufus-scheduler are you using?
wintersolutions
@wintersolutions
Hi, Im using 3.6 see above... I think I found a workaround:
John Mettraux
@jmettraux
ah sorry, I should have noticed
wintersolutions
@wintersolutions
I pause the individual jobs, on resume I set the job.next_time
that seems to work
John Mettraux
@jmettraux
another idea, have a guard inside the job: if !paused? {}
wintersolutions
@wintersolutions
Don't think this will work since the paused? attribute is probably already set to falseif I resume, right?
John Mettraux
@jmettraux
yes, you are right
wintersolutions
@wintersolutions
Another question: shouldn't the paused_at attribute on the individual jobs be set when I pause the whole singleton/thread the job belongs to?
John Mettraux
@jmettraux
no, the scheduler is paused, not the job
wintersolutions
@wintersolutions
ok
well thanks again for your help, the workaround is quick and easy
John Mettraux
@jmettraux
you're welcome, well done with your workaround!
wintersolutions
@wintersolutions
ty ;)
I stand on the shoulders of giants ;)
John Mettraux
@jmettraux
me too !
wintersolutions
@wintersolutions

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

thanks again!

https://gist.github.com/wintersolutions/689588ecc2caaf36809ed6c6ffb028f3

John Mettraux
@jmettraux
thanks for sharing!
John Mettraux
@jmettraux
in the documentation, I state that discard_past: is on by default for rufus-scheduler >= 3.0
https://github.com/jmettraux/rufus-scheduler/blob/master/README.md#notable-changes
But, as we just saw, this isn't true. I will fix/change that. jmettraux/rufus-scheduler#290
wintersolutions
@wintersolutions
Wow nice!
wintersolutions
@wintersolutions
Would discard_past: been a parameter for resume on job/scheduler?
John Mettraux
@jmettraux
yes, and I was also planning to have it at scheduler and at job level
wintersolutions
@wintersolutions
Allright feel free to use my code as you see fit if you need it (if this was not obvious already)
John Mettraux
@jmettraux
ok, thanks. This gist helps a lot