-
Notifications
You must be signed in to change notification settings - Fork 218
Description
SolidQueue uses fugit to parse recurring tasks schedules. If you enter a schedule in natural language that generates multiple CRONs, only the first CRON is considered, and the other CRONs are ignored without warning. It might be a good idea to raise an error or a warning when that happens.
Normal case
For normal cases, with schedule
schedule: every day at 00:40The corresponding fugit translation would result in this object.
> require 'fugit'; Fugit.parse('every day at 00:40')
#<Fugit::Cron:0x00007f5e11978d50
@cron_s=nil,
@day_and=nil,
@hours=[0],
@minutes=[40],
@monthdays=nil,
@months=nil,
@original="40 0 * * *",
@seconds=[0],
@timezone=nil,
@weekdays=nil,
@zone=nil>For schedules that only generate a single CRON like this:
schedule: every day at 00:40 and 15:40The corresponding fugit translation results in this object:
#<Fugit::Cron:0x00007f5e116858c8
@cron_s=nil,
@day_and=nil,
@hours=[0, 15],
@minutes=[40],
@monthdays=nil,
@months=nil,
@original="40 0,15 * * *",
@seconds=[0],
@timezone=nil,
@weekdays=nil,
@zone=nil>Breaking case
However, for schedules that cannot be converted via fugit to a single CRON, like this
schedule: every day at 00:40 and 15:20The corresponding fugit trims off the second schedule entirely and only results in:
#<Fugit::Cron:0x00007f5e117d43a0
@cron_s=nil,
@day_and=nil,
@hours=[0],
@minutes=[40],
@monthdays=nil,
@months=nil,
@original="40 0 * * *",
@seconds=[0],
@timezone=nil,
@weekdays=nil,
@zone=nil>This results in solid_queue only running the recurring task at one time and not reporting a failure.
Possible solution
A possible solution would be to use Fugit::Nat to parse and have multi: fail set to true.
schedule: every day at 00:40 and 15:20Fugit::Nat.parse('every day at 00:40 and 15:20', multi: :fail)
(app):7:in '<top (required)>': multiple crons in "every day at 00:40 and 15:20" - {monthday: (slot :monthday "*" {weak: true})} (ArgumentError)Or, for a safer approach if solid_queue can support multi CRONs,
Fugit::Nat.parse('every day at 00:40 and 15:20', multi: true)
=>
[#<Fugit::Cron:0x00007f5e116ab0f0
@cron_s=nil,
@day_and=nil,
@hours=[0],
@minutes=[40],
@monthdays=nil,
@months=nil,
@original="40 0 * * *",
@seconds=[0],
@timezone=nil,
@weekdays=nil,
@zone=nil>,
#<Fugit::Cron:0x00007f5e116aae70
@cron_s=nil,
@day_and=nil,
@hours=[15],
@minutes=[20],
@monthdays=nil,
@months=nil,
@original="20 15 * * *",
@seconds=[0],
@timezone=nil,
@weekdays=nil,
@zone=nil>]Hope the description helps. Thought it would be a good idea to report this in case someone else goes through something similar and cannot debug why the recurring task is not running as expected.