Uninitialized constant for ActiveRecord model in script/delayed_job, but not rake jobs:work
I'm using Rails 2.3.8 with Ruby 1.8.7. I've made a new ActiveRecord model called Foo
(generated using script/generate model Foo ...
) with a method #self.bar(x, y)
and in a controller I call Foo.send_later(:bar, x, y)
. On my (Windows) development environment this works fine when I'm running rake jobs:work
. On my (Linux) production environment, this also works if I'm running rake jobs:work RAILS_ENV=production
, but if i'm running RAILS_ENV=production script/delayed_job start
, in the delayed_job.log I get
2011-02-19T12:27:11-0800: * [Worker(delayed_job host:myhost pid:3673)] acquired lock on Foo.bar
Could not load object for job: uninitialized constant Foo
2011-02-19T12:27:11-0800: * [JOB] delayed_job host:myhost pid:3673 completed after 0.0024
2011-02-19T12:27:11-0800: 1 jobs proces开发者_如何学编程sed at 32.4446 j/s, 0 failed ...
My other delayed jobs work fine, only this new one has a problem. Foo
is accessible from script/console production
, and I've tried touch tmp/restart.txt
or even restarting apache2 and then restarting the delayed_job script, but there was no change.
Has anyone seen this problem before?
Use rake jobs:work
in a screen
session or, less hacky, run it using the god
gem or monit
so that if the process dies it will be "resurrected".
精彩评论