Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Install resque-scheduler, configure a basic schedule

  • Loading branch information...
commit 5d71ebed7cc81a9bb8d07d19d24ba371d8418088 1 parent 73cc0d0
Chris White authored
1  Gemfile
View
@@ -36,6 +36,7 @@ gem 'devise', '~> 1.5.3'
# Used for queued mail sending
gem 'resque', '~> 1.19.0'
+gem 'resque-scheduler', '~> 1.9.9'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
7 Gemfile.lock
View
@@ -150,6 +150,10 @@ GEM
redis-namespace (~> 1.0.2)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
+ resque-scheduler (1.9.9)
+ redis (>= 2.0.1)
+ resque (>= 1.8.0)
+ rufus-scheduler
rich (0.0.8)
jquery-rails
kaminari
@@ -158,6 +162,8 @@ GEM
rack-raw-upload
rails (>= 3.1.0)
sass-rails
+ rufus-scheduler (2.0.16)
+ tzinfo (>= 0.3.23)
sass (3.1.12)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
@@ -209,6 +215,7 @@ DEPENDENCIES
mysql (~> 2.8.1)
rails (= 3.1.3)
resque (~> 1.19.0)
+ resque-scheduler (~> 1.9.9)
rich (~> 0.0.8)
sass-rails (~> 3.1.5)
therubyracer (~> 0.9.9)
1  config.ru
View
@@ -6,6 +6,7 @@ resque_config = YAML.load_file(File.join(Rails.root, 'config', 'resque-pw.yml'))
# This shows resque-web at /resque
require 'resque/server'
+require 'resque/scheduler'
Resque::Server.use Rack::Auth::Basic do |username, password|
username == resque_config['username'] && password == resque_config['password']
end
3  config/initializers/resque.rb
View
@@ -0,0 +1,3 @@
+require 'resque_scheduler'
+
+Resque.schedule = YAML.load_file("#{Rails.root}/config/resque_schedule.yml")
4 config/resque_schedule.yml
View
@@ -0,0 +1,4 @@
+send_daily_email:
+ cron: "0 7 * * *"
+ class: SendDailyEmail
+ description: "If there is a DevotionDay to send out today, send it!"
19 lib/tasks/resque.rake
View
@@ -1 +1,18 @@
-require 'resque/tasks'
+require 'resque/tasks'
+require 'resque_scheduler/tasks'
+
+namespace :resque do
+ task :setup do
+ require 'resque'
+ require 'resque_scheduler'
+ require 'resque/scheduler'
+
+ # you probably already have this somewhere
+ Resque.redis = 'localhost:6379'
+
+ # The schedule doesn't need to be stored in a YAML, it just needs to
+ # be a hash. YAML is usually the easiest.
+ Resque.schedule = YAML.load_file("#{Rails.root}/config/resque_schedule.yml")
+
+ end
+end
3  procfile.example.dev
View
@@ -1,2 +1,3 @@
web: bundle exec thin start -p 3000
-worker: bundle exec rake environment resque:work QUEUE=*
+worker: bundle exec rake environment resque:work QUEUE=*
+scheduler: bundle exec rake resque:scheduler
Please sign in to comment.
Something went wrong with that request. Please try again.