0

我在让工作守护程序正常工作时遇到问题。当我运行时:

ruby script/workling_client run

守护进程开始加载rails,但无限期地挂起。当我终止进程时,堆栈跟踪总是相同的:

/Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/core_ext/load_error.rb:32:in `new': Interrupt
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:355:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:510:in `require'
from /Library/Ruby/Gems/1.8/gems/httpclient-2.1.2/lib/httpclient.rb:68
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
 ... 81 levels...
from /Library/Ruby/Gems/1.8/gems/daemons-1.0.10/lib/daemons/cmdline.rb:105:in `call'
from /Library/Ruby/Gems/1.8/gems/daemons-1.0.10/lib/daemons/cmdline.rb:105:in `catch_exceptions'
from /Library/Ruby/Gems/1.8/gems/daemons-1.0.10/lib/daemons.rb:138:in `run'
from script/workling_client:18

如果我在没有守护程序库的情况下运行脚本,它会按预期工作。事实上,我在使用守护进程 gem 加载任何需要我的 rails 环境的东西时遇到了麻烦。有任何想法吗?

更新: workling_client 将 worklings listen.rb 作为守护进程加载。我没有在listen.rb中加载rails,而是对其进行了更改,以便将其加载到workling_client中,并且该过程可以顺利进行。因此,我无法在守护脚本中加载 rails 是有原因的 :-(

4

2 回答 2

1

您可以发布启动守护程序脚本的代码吗?我知道可以在守护程序脚本中加载 rails,因为我们是为 delay_jobs 脚本执行的。

脚本的初始部分执行以下操作:

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config',
      'environment'))

调整您的 rails 项目中的 environment.rb 文件。然后,该过程继续进行自己的守护进程:

Worker::Command.new(ARGV, :workers => worker_config).daemonize

我们的脚本在执行 daemonize 步骤之前加载 rails。如果这不起作用,请包括您的脚本如何加载导轨。

于 2011-02-09T17:31:41.523 回答
0

尝试在没有监视器的情况下开始工作:

options = {
  :app_name   => "workling",
  :ARGV       => ARGV,
  :dir_mode   => :normal,
  :dir        => File.join(File.dirname(__FILE__), '..', 'log'),
  :log_output => true,
  :multiple   => false,
  :backtrace  => true,
  :monitor    => false
}
于 2010-11-30T02:41:38.820 回答