schedule and display only schedulable jobs
This commit is contained in:
parent
0e3e6eb62a
commit
899047b656
1 changed files with 8 additions and 6 deletions
|
@ -1,15 +1,17 @@
|
|||
namespace :jobs do
|
||||
desc 'Schedule all cron jobs'
|
||||
desc 'Schedule all schedulable 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)
|
||||
schedulable_jobs.each(&:schedule)
|
||||
end
|
||||
|
||||
desc 'Display schedule for all cron jobs'
|
||||
desc 'Display schedule for all schedulable cron jobs'
|
||||
task display_schedule: :environment do
|
||||
schedulable_jobs.each(&:display_schedule)
|
||||
end
|
||||
|
||||
def schedulable_jobs
|
||||
glob = Rails.root.join('app', 'jobs', '**', '*_job.rb')
|
||||
Dir.glob(glob).each { |f| require f }
|
||||
Cron::CronJob.subclasses.each(&:display_schedule)
|
||||
Cron::CronJob.subclasses.filter(&:schedulable?)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue