Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 05 21:53
    jmettraux closed #23
  • Dec 05 21:53
    jmettraux commented #23
  • Dec 05 21:52

    jmettraux on master

    Document Chronic disabling, gh-… (compare)

  • Nov 25 07:50

    jmettraux on master

    Change spec title, gh-24 Add .chronic_enabled? .chronic_… (compare)

  • Nov 25 07:03

    jmettraux on master

    Refine around gh-24 optional Ch… Credit Stan Hu (compare)

  • Nov 25 06:43

    jmettraux on master

    Integrate gh-27 for gh-26, Chro… (compare)

  • Nov 25 06:38
    jmettraux closed #27
  • Nov 25 06:38
    jmettraux commented #27
  • Nov 25 06:37
    jmettraux closed #25
  • Nov 25 06:25

    jmettraux on master

    Fix gh-26 for older Rubies and … (compare)

  • Nov 25 06:24
    stanhu commented #23
  • Nov 25 06:21
    stanhu opened #27
  • Nov 25 06:12

    jmettraux on master

    Filter out only allowed options… Merge pull request #26 from sta… (compare)

  • Nov 25 06:12
    jmettraux closed #26
  • Nov 25 06:07
    jmettraux commented #26
  • Nov 25 06:06
    jmettraux commented #23
  • Nov 25 06:06
    stanhu commented #26
  • Nov 25 06:00
    jmettraux commented #26
  • Nov 25 05:58
    jmettraux assigned #26
  • Nov 25 05:50
    stanhu commented #23
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