From 4aeb29891eeca79e8679b0ff3702a9c906f0b3f5 Mon Sep 17 00:00:00 2001 From: MichaelAChrisco Date: Fri, 3 Apr 2015 10:50:24 -0700 Subject: [PATCH] Rake Tasks --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 8832126..180a8e5 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,33 @@ class TestJob # This is not an Active Job job, but pretty legal Crono job. end ``` +Here's an example of a Rake Task within a job: + +```ruby +# config/cronotab.rb +require 'rake' +# Be sure to change AppName to your application name! +AppName::Application.load_tasks + +class Test + def perform + Rake::Task['crono:hello'].invoke + end +end + +Crono.perform(Test).every 5.seconds +``` +With the rake task of: +```Ruby +# lib/tasks/test.rake +namespace :crono do + desc 'Update all tables' + task :hello => :environment do + puts "hello" + end +end +``` + _Please note that crono uses threads, so your code should be thread-safe_ #### Job Schedule