diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 9e511e4e5..1c8d76756 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -23,21 +23,22 @@ if Sidekiq.server? end end - require 'scheduler/scheduler' - - manager = Scheduler::Manager.new - Scheduler::Manager.discover_schedules.each do |schedule| - manager.ensure_schedule!(schedule) - end - Thread.new do - while true - begin - manager.tick - rescue => e - # the show must go on - Discourse.handle_exception(e) + Rails.application.config.after_initialize do + require 'scheduler/scheduler' + manager = Scheduler::Manager.new + Scheduler::Manager.discover_schedules.each do |schedule| + manager.ensure_schedule!(schedule) + end + Thread.new do + while true + begin + manager.tick + rescue => e + # the show must go on + Discourse.handle_exception(e) + end + sleep 1 end - sleep 1 end end end