demarches-normaliennes/lib/tasks/jobs.rake
2020-12-08 15:21:35 +01:00

15 lines
490 B
Ruby

namespace :jobs do
desc 'Schedule all cron jobs'
task schedule: :environment do
glob = Rails.root.join('app', 'jobs', '**', '*_job.rb')
Dir.glob(glob).each { |f| require f }
Cron::CronJob.subclasses.each(&:schedule)
end
desc 'Display schedule for all cron jobs'
task display_schedule: :environment do
glob = Rails.root.join('app', 'jobs', '**', '*_job.rb')
Dir.glob(glob).each { |f| require f }
Cron::CronJob.subclasses.each(&:display_schedule)
end
end