Start up the Job scheduler after all the other initializers have loaded.

We do this so that plugins can register scheduled jobs.
This commit is contained in:
Robin Ward 2014-04-10 12:40:49 -04:00
parent e1b96d2f15
commit caa2564b83
1 changed files with 15 additions and 14 deletions

View File

@ -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