defunkt/resque — Issue #536: preloading controller objects
Author: jasonfb
Created: 2012-03-07 02:50:26+00:00
State: open

I see that there was some discussion about preloading Rails classes in this thread about 6 months ago:

https://github.com/defunkt/resque/issues/369

but I'm still getting crashed worker processes with this:

2012-03-07T02:41:43+00:00 app[worker.1]: rake aborted!
2012-03-07T02:41:43+00:00 app[worker.1]: No such file to load -- admin/announcements_controller
2012-03-07T02:41:43+00:00 app[worker.1]:
2012-03-07T02:41:43+00:00 app[worker.1]: Tasks: TOP => resque:work => resque:preload
2012-03-07T02:41:43+00:00 app[worker.1]: (See full trace by running task with --trace)
2012-03-07T02:41:44+00:00 heroku[worker.1]: Process exited with status 1
2012-03-07T02:41:44+00:00 heroku[worker.1]: State changed from up to crashed

(this is on heroku of course).

My Procfile is as such:

web: bundle exec rails server thin -p $PORT
worker: QUEUE=* bundle exec rake resque:work

And I have this in lib/tasks/resque.task :

require 'resque/tasks'
task "resque:setup" => :environment do
ENV['QUEUE'] = '*'
Resque.after_fork do |job|
ActiveRecord::Base.establish_connection
end
end
desc "Alias for resque:work (To run workers on Heroku)"
task "jobs:work" => "resque:work"

My Gemfile.lock says I'm running resque-1.20.0

Any ideas why I'm getting that No such file to load -- admin/announcements_controller ?

admin/announcements_controller is indeed one of my controllers and it is also the first alphabetically (no surprise) so it seems like a preload issue.

I've never set-up resque before so it could be something I've missed in the setup.