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 'nokogiri'
|
||||||
gem 'radius'
|
gem 'radius'
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
gem 'resque-scheduler', :require => 'resque_scheduler'
|
gem 'resque' # background jobs
|
||||||
gem 'resque', :require => "resque/server"
|
gem 'resque-scheduler' # job scheduling
|
||||||
gem 'ruby-debug19'
|
gem 'ruby-debug19'
|
||||||
gem 'rubyzip'
|
gem 'rubyzip'
|
||||||
gem 'sinatra'
|
gem 'sinatra'
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
require 'open-uri'
|
# require 'open-uri'
|
||||||
require 'nokogiri'
|
# require 'nokogiri'
|
||||||
module FetchTime
|
module FetchTime
|
||||||
@queue = :fetch_time
|
@queue = :my_job_queue
|
||||||
|
|
||||||
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,15 +1,20 @@
|
||||||
require 'resque_scheduler'
|
require 'resque_scheduler'
|
||||||
require 'resque_scheduler/server'
|
# require 'resque_scheduler/server'
|
||||||
require 'yaml'
|
# require 'yaml'
|
||||||
|
|
||||||
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
|
Resque.redis = 'localhost:6379'
|
||||||
rails_env = ENV['RAILS_ENV'] || 'development'
|
Resque.redis.namespace = "resque:SchedulerExample"
|
||||||
|
|
||||||
resque_config = YAML.load_file(rails_root + '/config/resque.yml')
|
# If you want to be able to dynamically change the schedule,
|
||||||
Resque.redis = resque_config[rails_env]
|
# 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 }
|
Dir["#{Rails.root}/app/jobs/*.rb"].each { |file| require file }
|
||||||
|
|
||||||
# current_path = Rails.root.to_s.gsub(/\s/,'\ ')
|
# The schedule doesn't need to be stored in a YAML, it just needs to
|
||||||
# queues = [:test]
|
# 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:
|
do_my_job:
|
||||||
cron: "*/5 * * * *"
|
every: 30s
|
||||||
class: FetchTime
|
class: FetchTime
|
||||||
queue: daemons
|
args:
|
||||||
rails_env: development
|
description: Runs the perform method in MyJob
|
||||||
description: Send Email for Remind Time
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Orbit::Application.routes.draw do
|
Orbit::Application.routes.draw do
|
||||||
|
mount Resque::Server, :at => "/admin/resque"
|
||||||
devise_for :users
|
devise_for :users
|
||||||
|
|
||||||
# routes for sinatra app
|
# routes for sinatra app
|
||||||
|
|
Loading…
Reference in New Issue