Permalink
Browse files

Merb-ify.

Signed-off-by: Tobias Lütke <tobi@leetsoft.com>
  • Loading branch information...
1 parent af8e10c commit c08971b7b16f64e25de4e07e1f8d1e8426fa9c5c Dean Strelau committed with tobi Dec 29, 2008
Showing with 24 additions and 2 deletions.
  1. +1 −0 delayed_job.gemspec
  2. +5 −1 lib/delayed/worker.rb
  3. +7 −1 lib/delayed_job.rb
  4. +11 −0 tasks/merbtasks.rb
View
1 delayed_job.gemspec
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
lib/delayed/worker.rb
lib/delayed_job.rb
tasks/jobs.rake
+ tasks/merbtasks.rb
]
s.test_files = %w[
spec/database.rb
View
6 lib/delayed/worker.rb
@@ -3,7 +3,11 @@ class Worker
SLEEP = 5
cattr_accessor :logger
- self.logger = RAILS_DEFAULT_LOGGER if const_defined?(:RAILS_DEFAULT_LOGGER)
+ self.logger = if defined?(Merb::Logger)
+ Merb.logger
+ elsif defined?(RAILS_DEFAULT_LOGGER)
+ RAILS_DEFAULT_LOGGER
+ end
def initialize(options={})
@quiet = options[:quiet]
View
8 lib/delayed_job.rb
@@ -1,6 +1,12 @@
+autoload :ActiveRecord, 'activerecord'
+
require File.dirname(__FILE__) + '/delayed/message_sending'
require File.dirname(__FILE__) + '/delayed/performable_method'
require File.dirname(__FILE__) + '/delayed/job'
require File.dirname(__FILE__) + '/delayed/worker'
-Object.send(:include, Delayed::MessageSending)
+Object.send(:include, Delayed::MessageSending)
+
+if defined?(Merb::Plugins)
+ Merb::Plugins.add_rakefiles File.dirname(__FILE__) / '..' / 'tasks' / 'merbtasks'
+end
View
11 tasks/merbtasks.rb
@@ -0,0 +1,11 @@
+namespace :jobs do
+ desc "Clear the delayed_job queue."
+ task :clear => :merb_env do
+ Delayed::Job.delete_all
+ end
+
+ desc "Start a delayed_job worker."
+ task :work => :merb_env do
+ Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY']).start
+ end
+end

0 comments on commit c08971b

Please sign in to comment.