Skip to content

Commit cb371b4

Browse files
committed
Use RAILS_ROOT in preload task
1 parent 7e4e0ef commit cb371b4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/resque/tasks.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
task :setup
66

77
desc "Start a Resque worker"
8-
task :work => :setup do
8+
task :work => [ :preload, :setup ] do
99
require 'resque'
1010

1111
queues = (ENV['QUEUES'] || ENV['QUEUE']).to_s.split(',')
@@ -39,11 +39,13 @@
3939

4040
threads.each { |thread| thread.join }
4141
end
42-
end
4342

44-
# Preload app files
45-
task :environment do
46-
Dir['app/**/*.rb'].each do |file|
47-
require file
43+
# Preload app files if this is Rails
44+
task :preload do
45+
if defined? RAILS_ROOT
46+
Dir["#{RAILS_ROOT}/app/**/*.rb"].each do |file|
47+
require file
48+
end
49+
end
4850
end
4951
end

0 commit comments

Comments
 (0)