From 1aee217a61643e972403c2258051a9d200de2f1f Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 10 Jan 2014 11:43:24 -0500 Subject: [PATCH] FIX: sidekiq 100% CPU usage due to `ice_cube` --- app/jobs/scheduled/poll_mailbox.rb | 2 +- lib/freedom_patches/ice_cube.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 lib/freedom_patches/ice_cube.rb diff --git a/app/jobs/scheduled/poll_mailbox.rb b/app/jobs/scheduled/poll_mailbox.rb index ca96fd87211..750a7ecfe2b 100644 --- a/app/jobs/scheduled/poll_mailbox.rb +++ b/app/jobs/scheduled/poll_mailbox.rb @@ -6,7 +6,7 @@ require_dependency 'email/receiver' module Jobs class PollMailbox < Jobs::Scheduled - recurrence { minutely(5) } + recurrence { hourly.minute_of_hour(0,5,10,15,20,25,30,35,40,45,50,55) } sidekiq_options retry: false def execute(args) diff --git a/lib/freedom_patches/ice_cube.rb b/lib/freedom_patches/ice_cube.rb new file mode 100644 index 00000000000..3e17477e744 --- /dev/null +++ b/lib/freedom_patches/ice_cube.rb @@ -0,0 +1,16 @@ +module IceCube + class MinutelyRule < ValidatedRule + def initialize(interval = 1, week_start = :sunday) + super + + unless interval == 1 + raise "Due to a gigantic awful bug in ice_cube, don't specify an interval for minutely. Use `hourly.minute_of_hour`" + end + + interval(interval) + schedule_lock(:sec) + reset + end + end +end +