3

我有一个非常简单的工作:

class MyJob
  @queue = :high

  def self.perform(user_id)
    user = User.find(user_id)
    MyMailer.send_email(user).deliver
  end

end

如果我手动运行它,MyJob.perform(some_id)它会完美运行。但是,当 Rescue 执行它时,它会返回此错误:

Exception
    Errno::ENOENT Error
    No such file or directory - getcwd

 shared/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/template/resolver.rb:221:in `expand_path'  shared/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/template/resolver.rb:221:in `initialize'  shared/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/template/resolver.rb:251:in `new'  shared/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/template/resolver.rb:251:in `instances'  shared/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/lookup_context.rb:16:in `<class:LookupContext>'  shared/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/lookup_context.rb:12:in `<module:ActionView>'  shared/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/action_view/lookup_context.rb:5:in `<top (required)>'  shared/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/abstract_controller/view_paths.rb:45:in `lookup_context'  shared/bundle/ruby/1.9.1/gems/actionmailer-3.2.12/lib/action_mailer/base.rb:456:in `process'  shared/bundle/ruby/1.9.1/gems/actionmailer-3.2.12/lib/action_mailer/base.rb:452:in `initialize'  shared/bundle/ruby/1.9.1/gems/actionmailer-3.2.12/lib/action_mailer/base.rb:439:in `new'  shared/bundle/ruby/1.9.1/gems/actionmailer-3.2.12/lib/action_mailer/base.rb:439:in `method_missing'  releases/1111111111111/app/jobs/my_job.rb:6:in `perform'

有什么想法为什么会发生?

谢谢!

4

2 回答 2

2

是的天空。你是对的,它需要重新启动。

有些人在尝试从已删除的目录运行后收到此错误。

我在切换数据库并让服务器运行后收到此错误。旧的服务器信息仍在显示,但我收到此错误。重新启动我的 Rails 服务器,新数据库一切正常。

基本上这意味着服务器上的状态发生了重大变化,您的环境需要重置/重新启动。

于 2014-04-27T17:32:21.860 回答
1

我开始在我的生产环境中遇到同样的问题。经过一番调查,我发现这是由于我的 resque 工作人员未能在每次 capistrano 部署时正确重新启动造成的。

于 2013-06-10T18:13:03.123 回答