Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Finishing up resque:scheduler rake task

  • Loading branch information...
commit 96e26c2ba8eacf156edb0dd8ae02de200c70f9f1 1 parent e240e3d
Ben VandenBos authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.