starting Resque
This commit is contained in:
parent
f949523bbb
commit
f3b58ea36d
5
Gemfile
5
Gemfile
|
@ -19,9 +19,8 @@ gem "mongo_session_store-rails3"
|
||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
gem 'radius'
|
gem 'radius'
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
gem 'resque' # background jobs
|
gem 'resque-scheduler', :require => 'resque_scheduler'
|
||||||
gem 'resque-scheduler' # job scheduling
|
gem 'resque', :require => "resque/server"
|
||||||
gem 'resque-restriction'
|
|
||||||
gem 'ruby-debug19'
|
gem 'ruby-debug19'
|
||||||
gem 'rubyzip'
|
gem 'rubyzip'
|
||||||
gem 'sinatra'
|
gem 'sinatra'
|
||||||
|
|
|
@ -161,8 +161,6 @@ GEM
|
||||||
redis-namespace (~> 1.0.2)
|
redis-namespace (~> 1.0.2)
|
||||||
sinatra (>= 0.9.2)
|
sinatra (>= 0.9.2)
|
||||||
vegas (~> 0.1.2)
|
vegas (~> 0.1.2)
|
||||||
resque-restriction (0.3.0)
|
|
||||||
resque (>= 1.7.0)
|
|
||||||
resque-scheduler (1.9.9)
|
resque-scheduler (1.9.9)
|
||||||
redis (>= 2.0.1)
|
redis (>= 2.0.1)
|
||||||
resque (>= 1.8.0)
|
resque (>= 1.8.0)
|
||||||
|
@ -278,7 +276,10 @@ DEPENDENCIES
|
||||||
rails (>= 3.1.0, < 3.2.0)
|
rails (>= 3.1.0, < 3.2.0)
|
||||||
rake
|
rake
|
||||||
resque
|
resque
|
||||||
|
<<<<<<< HEAD
|
||||||
resque-restriction
|
resque-restriction
|
||||||
|
=======
|
||||||
|
>>>>>>> starting Resque
|
||||||
resque-scheduler
|
resque-scheduler
|
||||||
rspec (~> 2.0)
|
rspec (~> 2.0)
|
||||||
rspec-rails (~> 2.0)
|
rspec-rails (~> 2.0)
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
# require 'open-uri'
|
require 'open-uri'
|
||||||
# require 'nokogiri'
|
require 'nokogiri'
|
||||||
class FetchTime < Resque::Plugins::RestrictionJob
|
module FetchTime
|
||||||
restrict :per_300 => 10
|
@queue = :fetch_time
|
||||||
|
|
||||||
@queue = :low
|
|
||||||
|
|
||||||
def self.perform()
|
def self.perform()
|
||||||
# sleep 10
|
sleep 10
|
||||||
doc = Nokogiri::HTML(open('http://www.timeanddate.com/worldclock/city.html?n=241'))
|
doc = Nokogiri::HTML(open('http://www.timeanddate.com/worldclock/city.html?n=241'))
|
||||||
CronMail.time_check(doc.at('#ct').children.first.text).deliver
|
CronMail.time_check(doc.at('#ct').children.first.text).deliver
|
||||||
puts "Mail Sent"
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
require 'resque_scheduler'
|
require 'resque_scheduler'require 'resque_scheduler/server'
|
||||||
# require 'resque_scheduler/server'
|
require 'yaml'
|
||||||
# require 'yaml'
|
|
||||||
|
|
||||||
Resque.redis = 'localhost:6379'
|
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
|
||||||
#Resque.redis.namespace = "resque:SchedulerExample"
|
rails_env = ENV['RAILS_ENV'] || 'development'
|
||||||
|
|
||||||
# If you want to be able to dynamically change the schedule,
|
resque_config = YAML.load_file(rails_root + '/config/resque.yml')
|
||||||
# uncomment this line. A dynamic schedule can be updated via the
|
Resque.redis = resque_config[rails_env]
|
||||||
# Resque::Scheduler.set_schedule (and remove_schedule) methods.
|
|
||||||
# When dynamic is set to true, the scheduler process looks for
|
|
||||||
# schedule changes and applies them on the fly.
|
|
||||||
# Note: This feature is only available in >=2.0.0.
|
|
||||||
#Resque::Scheduler.dynamic = true
|
|
||||||
|
|
||||||
|
Resque.schedule = YAML.load_file("#{Rails.root}/config/resque_schedule.yml")
|
||||||
Dir["#{Rails.root}/app/jobs/*.rb"].each { |file| require file }
|
Dir["#{Rails.root}/app/jobs/*.rb"].each { |file| require file }
|
||||||
|
|
||||||
# The schedule doesn't need to be stored in a YAML, it just needs to
|
# current_path = Rails.root.to_s.gsub(/\s/,'\ ')
|
||||||
# be a hash. YAML is usually the easiest.
|
# queues = [:test]
|
||||||
Resque.schedule = YAML.load_file(Rails.root.join('config', 'resque_schedule.yml'))
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
development: localhost:6379
|
||||||
|
production: localhost:6379
|
|
@ -1,17 +1,6 @@
|
||||||
do_mail_matt:
|
time_to_talk_a_rest:
|
||||||
every: 10s
|
cron: "*/5 * * * *"
|
||||||
class: FetchTime
|
class: FetchTime
|
||||||
args:
|
queue: daemons
|
||||||
description: Runs the perform method in FetchTime
|
rails_env: development
|
||||||
|
description: Send Email for Remind Time
|
||||||
nccu_daily_ldap_sync:
|
|
||||||
cron: 30 * * * * *
|
|
||||||
class: SyncDb
|
|
||||||
args:
|
|
||||||
description: Runs the perform method in SnycDB
|
|
||||||
|
|
||||||
nccu_claender_sync:
|
|
||||||
every: 1m
|
|
||||||
class: NccuCalendar
|
|
||||||
args:
|
|
||||||
description: Runs the perform method in NccuCalendar
|
|
||||||
|
|
Loading…
Reference in New Issue