now jobs is working
This commit is contained in:
parent
c28d7d59b6
commit
69f2f6a716
4
Gemfile
4
Gemfile
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
require 'resque_scheduler'
|
||||
require 'resque_scheduler/server'
|
||||
require 'yaml'
|
||||
# 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'))
|
|
@ -1,2 +0,0 @@
|
|||
development: localhost:6379
|
||||
production: localhost:6379
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Orbit::Application.routes.draw do
|
||||
|
||||
mount Resque::Server, :at => "/admin/resque"
|
||||
devise_for :users
|
||||
|
||||
# routes for sinatra app
|
||||
|
|
Reference in New Issue