Permalink
Browse files

Finishing up resque:scheduler rake task

  • Loading branch information...
1 parent e240e3d commit 96e26c2ba8eacf156edb0dd8ae02de200c70f9f1 Ben VandenBos committed Dec 22, 2009
Showing with 8 additions and 5 deletions.
  1. +3 −1 README.markdown
  2. +2 −2 lib/resque/scheduler.rb
  3. +2 −2 lib/resque_scheduler.rb
  4. +1 −0 lib/resque_scheduler/tasks.rb
View
4 README.markdown
@@ -27,8 +27,9 @@ is most likely stored in a YAML:
args: moderators
description: "This job resets the weekly leaderboard for moderators"
-And then set the schedule like so:
+And then set the schedule where ever you configure Resque like so:
+ require 'resque-scheduler'
ResqueScheduler.schedule = YAML.load_file(File.join(File.dirname(__FILE__), '../resque_schedule.yml'))
The scheduler process is just a rake task which adds things to resque when they fire
@@ -38,6 +39,7 @@ based on the schedule:
You'll need to add this to your rakefile:
+ require 'resque_scheduler/tasks'
task "resque:setup" => :environment
View
4 lib/resque/scheduler.rb
@@ -1,7 +1,6 @@
require 'rufus-scheduler'
require 'rufus/scheduler'
require 'thwait'
-require 'resque'
module Resque
@@ -15,7 +14,8 @@ class << self
def run(wait = true)
puts "Schedule empty! Set Resque.schedule" if Resque.schedule.empty?
- Resque.schedule.values.each do |config|
+ Resque.schedule.each do |name, config|
+ puts "Adding #{name} to the schedule"
rufus_scheduler.cron config['cron'] do
enqueue_from_config(config)
end
View
4 lib/resque_scheduler.rb
@@ -1,5 +1,5 @@
-
-
+require 'rubygems'
+require 'resque'
require 'resque_scheduler/version'
require 'resque/scheduler'
View
1 lib/resque_scheduler/tasks.rb
@@ -7,6 +7,7 @@
desc "Start Resque Scheduler"
task :scheduler => :setup do
require 'resque'
+ require 'resque_scheduler'
Resque::Scheduler.run
end

0 comments on commit 96e26c2

Please sign in to comment.