救援工人生产失败
我有一个包含以下内容的模型:
def fetch_austlii
Resque.enqueue(FetchAustliiJob, self.id) # Queue the job for later.
end
这会调度 app/workers/fetch_austlii_job.rb 文件:
class FetchAustliiJob
@queue = :fetch_queue
def self.perform(profile_id)
@profile = Profile.find(profile_id)
AustliiResource.fetch(@profile.name).each do |resource|
@profile.austlii_resources.create!(resource.attributes) if @profile.austlii_resources.find_all_by_url(resource.url).empty?
end
end
end
在开发中(OS X、Ruby 1.9.2、Rails3、Postgres、Redis-server、Foreman)它工作正常。该作业按照应有的方式从互联网检索信息。然而,在生产中(Ubuntu、Ruby 1.9.2、Passenger)它失败了:
Class
FetchAustliiJob
Arguments
2
Exception
NoMethodError
Error
undefined method `austlii_resources' for #<Profile:0x00000002fab6b0>
I have a model which contains the following:
def fetch_austlii
Resque.enqueue(FetchAustliiJob, self.id) # Queue the job for later.
end
This dispatches the app/workers/fetch_austlii_job.rb file:
class FetchAustliiJob
@queue = :fetch_queue
def self.perform(profile_id)
@profile = Profile.find(profile_id)
AustliiResource.fetch(@profile.name).each do |resource|
@profile.austlii_resources.create!(resource.attributes) if @profile.austlii_resources.find_all_by_url(resource.url).empty?
end
end
end
In development (OS X, Ruby 1.9.2, Rails3, Postgres, Redis-server, Foreman) it works fine. The job retrieves information from the internet just like it should. However, in production (Ubuntu, Ruby 1.9.2, Passenger) it fails with:
Class
FetchAustliiJob
Arguments
2
Exception
NoMethodError
Error
undefined method `austlii_resources' for #<Profile:0x00000002fab6b0>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您在服务器上正确的环境(生产与开发)中运行工作程序。
如果您还没有尝试过,您可能需要创建一个
config/setup_load_paths.rb
来加载 RVM 环境(来源:RVM 乘客文档):Make sure you're running the workers in the correct environment (production vs development) on the server.
If you haven't already tried, you may want to create a
config/setup_load_paths.rb
to load the RVM environment (source: RVM Passenger docs):