Created
May 25, 2012 13:53
-
-
Save IanVaughan/2788269 to your computer and use it in GitHub Desktop.
Trying to get Resque Delayed Jobs to work and show in resque-web view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'thread' | |
| require "config/environment" | |
| require "resque/server" | |
| rails_app = Rack::Builder.new do | |
| use Rails::Rack::LogTailer | |
| use Rails::Rack::Static | |
| run ActionController::Dispatcher.new | |
| end | |
| run Rack::URLMap.new \ | |
| "/" => rails_app, | |
| "/resque" => Resque::Server.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #./lib/jobs/deliver_job.rb | |
| class DeliverJob | |
| @queue = :delivery_queue | |
| def self.perform(id) | |
| # do something now! | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gem 'resque', :require => "resque/server" | |
| gem 'sinatra', '0.9.2' | |
| gem 'resque-scheduler', :require => 'resque_scheduler' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... #main app and other processes | |
| resque_test_worker: bundle exec rake resque:work QUEUE=test_queue | |
| resque_delivery_worker: bundle exec rake resque:work QUEUE=delivery_queue | |
| resque_scheduler: bundle exec rake resque:scheduler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #./lib/tasks/resque.rake | |
| require 'resque/tasks' | |
| require 'resque_scheduler/tasks' | |
| namespace :resque do | |
| task :setup => :environment do | |
| require 'resque' | |
| require 'resque_scheduler' | |
| require 'resque/scheduler' | |
| require 'resque_scheduler/server' | |
| rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..' | |
| rails_env = ENV['RAILS_ENV'] || 'development' | |
| config = YAML.load_file(rails_root + '/config/resque.yml') | |
| Resque.redis = config[rails_env] | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Not sure this is being pushed to a delayed job queue | |
| Resque.enqueue_in(1.minutes.from_now, DeliverJob, thing.id) | |
| ... | |
| # Normal Resque queue/workers are working | |
| Resque.enqueue(TestJob, id) |
Author
Author
No tasks ever get queued! :-
$ VERBOSE=1 bundle exec rake resque:scheduler
2012-05-26 09:27:09 Loading Schedule
2012-05-26 09:27:09 Schedule empty! Set Resque.schedule
2012-05-26 09:27:09 Schedules Loaded
Author
I've found a way to get it to show up, launch manually! (As per readme)
resque-web # doesnt work
resque-web ./config/resque.rb # works : show tabs!
But this is not a solution, as the normal resque-web is launched via config.ru when the rails app starts (And is automatically available in the app via the URLMap)
Also it requires a resque.rb file, when all my config is in the rake task resque.rake (This may be my misunderstanding of how to use Rake/resque!)
Author
So that was stupidly simple, just require resque-scheduler in config.rb!
require 'resque_scheduler'
require 'resque/scheduler'
require 'resque_scheduler/server'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I cannot get the Delayed Jobs tab to show?
I may of misunderstood how this works, but I want to use just Delayed Jobs, ie not scheduled jobs.
resque-webappMeta
Any help appreciated.