now jobs is working

This commit is contained in:
Matthew K. Fu JuYuan 2012-05-07 10:23:16 +08:00 committed by Christophe Vilayphiou
parent f3b58ea36d
commit dbac219c18
5 changed files with 29 additions and 24 deletions

View File

@ -19,8 +19,8 @@ gem "mongo_session_store-rails3"
gem 'nokogiri'
gem 'radius'
gem 'rake'
gem 'resque-scheduler', :require => 'resque_scheduler'
gem 'resque', :require => "resque/server"
gem 'resque' # background jobs
gem 'resque-scheduler' # job scheduling
gem 'ruby-debug19'
gem 'rubyzip'
gem 'sinatra'

View File

@ -1,11 +1,13 @@
require 'open-uri'
require 'nokogiri'
# require 'open-uri'
# require 'nokogiri'
module FetchTime
@queue = :fetch_time
@queue = :my_job_queue
def self.perform()
sleep 10
doc = Nokogiri::HTML(open('http://www.timeanddate.com/worldclock/city.html?n=241'))
CronMail.time_check(doc.at('#ct').children.first.text).deliver
# sleep 10
# doc = Nokogiri::HTML(open('http://www.timeanddate.com/worldclock/city.html?n=241'))
# CronMail.time_check(doc.at('#ct').children.first.text).deliver
# puts "Mail Sent"
# true
end
end

View File

@ -1,14 +1,20 @@
require 'resque_scheduler'require 'resque_scheduler/server'
require 'yaml'
require 'resque_scheduler'
# require 'resque_scheduler/server'
# require 'yaml'
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
rails_env = ENV['RAILS_ENV'] || 'development'
Resque.redis = 'localhost:6379'
Resque.redis.namespace = "resque:SchedulerExample"
resque_config = YAML.load_file(rails_root + '/config/resque.yml')
Resque.redis = resque_config[rails_env]
# If you want to be able to dynamically change the schedule,
# uncomment this line. A dynamic schedule can be updated via the
# 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 }
# current_path = Rails.root.to_s.gsub(/\s/,'\ ')
# queues = [:test]
# 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.join('config', 'resque_schedule.yml'))

View File

@ -1,2 +0,0 @@
development: localhost:6379
production: localhost:6379

View File

@ -1,6 +1,5 @@
time_to_talk_a_rest:
cron: "*/5 * * * *"
do_my_job:
every: 30s
class: FetchTime
queue: daemons
rails_env: development
description: Send Email for Remind Time
args:
description: Runs the perform method in MyJob