Sha256: 3c0dcbe371987798bf2511207881e81fbefc86c0cc2eb3cbfbc4b1e15cff38f1

Contents?: true

Size: 738 Bytes

Versions: 3

Compression:

Stored size: 738 Bytes

Contents

module Crono
  def self.load_cronotab
    cronotab_path = ENV['CRONOTAB'] || (defined?(Rails) &&
                      File.join(Rails.root, cronotab_path))
    fail 'No cronotab defined' unless cronotab_path
    puts "Load cronotab #{cronotab_path}"
    require cronotab_path
  end
end

namespace :crono do
  desc 'Clean unused job stats from DB'
  task clean: :environment do
    Crono.scheduler = Crono::Scheduler.new
    Crono.load_cronotab
    current_job_ids = Crono.scheduler.jobs.map(&:job_id)
    Crono::CronoJob.where.not(job_id: current_job_ids).destroy_all
  end

  desc 'Check cronotab.rb syntax'
  task check: :environment do
    Crono.scheduler = Crono::Scheduler.new
    Crono.load_cronotab
    puts 'Syntax ok'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
crono-0.8.7.pre lib/tasks/crono_tasks.rake
crono-0.8.6.pre lib/tasks/crono_tasks.rake
crono-0.8.1 lib/tasks/crono_tasks.rake