jmettraux / rufus-scheduler

scheduler for Ruby (at, in, cron and every jobs)
MIT License
2.41k stars 200 forks source link

Calls to `cron` can fail if fugit `Cron#rough_frequency` returns 0 #301

Closed dsander closed 4 years ago

dsander commented 4 years ago

Hi 👋 !

In some cases fugit seems to fail to calculate the rough_frequency for some cronlines (https://github.com/floraison/fugit/issues/36). If that happens and the scheduler frequency is greater than 1 second rufus-scheduler aborts with the following exception:

2: from /Users/dominik/code/ruby/rufus-scheduler/lib/rufus/scheduler.rb:227:in `cron'
1: from /Users/dominik/code/ruby/rufus-scheduler/lib/rufus/scheduler.rb:621:in `do_schedule'
/Users/dominik/code/ruby/rufus-scheduler/lib/rufus/scheduler/jobs.rb:667:in `check_frequency': job frequency (min ~0s) is higher than scheduler frequency (3s) (ArgumentError)

We at Huginn came across that issue because we are using a "bi-daily" cronline ('0 0 */2 * *') and a user is using a scheduler frequency of 3. The work around for the particular user is easy (reduce the frequency), but we as a project we can't upgrade to rufus-scheduler > 3.5.0 because we are exposing the frequency as a setting users can change.

Not is not urgent at all, we have been using an older version for a very long time without any issues.

jmettraux commented 4 years ago

Solved at the fugit level, fix included in fugit 1.3.4.

Many thanks!