Skip to content

Commit

Permalink
Merge e432085 into a4c3d65
Browse files Browse the repository at this point in the history
  • Loading branch information
albus522 committed Oct 3, 2014
2 parents a4c3d65 + e432085 commit a0e5f6d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/delayed/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def self.lifecycle
@lifecycle ||= Delayed::Lifecycle.new
end

def self.reload_app?
defined?(ActionDispatch::Reloader) && Rails.application.config.cache_classes == false
end

def initialize(options = {})
@quiet = options.key?(:quiet) ? options[:quiet] : true
@failed_reserve_count = 0
Expand Down Expand Up @@ -155,6 +159,7 @@ def start # rubocop:disable CyclomaticComplexity, PerceivedComplexity
break
elsif !stop?
sleep(self.class.sleep_delay)
reload!
end
else
say format("#{count} jobs processed at %.4f j/s, %d failed", count / @realtime, @result.last)
Expand Down Expand Up @@ -286,5 +291,11 @@ def reserve_job
raise FatalBackendError if @failed_reserve_count >= 10
nil
end

def reload!
return unless self.class.reload_app?
ActionDispatch::Reloader.cleanup!
ActionDispatch::Reloader.prepare!
end
end
end

0 comments on commit a0e5f6d

Please sign in to comment.