简体   繁体   English

Ruby守护程序挂在Rails负载上

[英]Ruby daemon hangs on rails load

I am having issues getting a workling daemon working correctly. 我在使工作守护程序正常工作时遇到问题。 When I run: 当我跑步时:

ruby script/workling_client run

the daemon starts to load rails, but hangs indefintely. 守护程序开始加载rails,但是不确定地挂起。 When I kill the process, the stack trace is always the same: 当我终止进程时,堆栈跟踪总是相同的:

/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

If I run the script without the daemons library, it works as expected. 如果我在没有守护程序库的情况下运行该脚本,则它将按预期工作。 I have, in fact, had trouble using the daemon gem to load anything that requires my rails environment. 实际上,我在使用守护程序gem加载需要我的rails环境的任何东西时遇到了麻烦。 Any ideas? 有任何想法吗?

UPDATE: The workling_client loads worklings listen.rb as a daemon. 更新:workling_client将工作文件listen.rb加载为守护程序。 Instead of loading rails in listen.rb, I changed it so that it gets loaded in workling_client instead, and the process works without a hitch. 我没有将其加载到listen.rb中,而是对其进行了更改,以便将其加载到workling_client中,并且该过程可以顺利进行。 Therefore, there is some reason that I can't load rails in a daemonized script :-( 因此,出于某些原因,我无法在守护程序脚本中加载rails :-(

Can you post the code that starts the daemon script? 您可以发布启动守护程序脚本的代码吗? I know it is possible to load rails in a daemons script since we do it for our delayed_jobs script. 我知道可以在daemons脚本中加载rails,因为我们是为delay_jobs脚本完成的。

The initial part of the script does: 该脚本的初始部分执行以下操作:

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

adjust for your environment.rb file in your rails project. 在Rails项目中针对您的environment.rb文件进行调整。 Then, the process proceeds to daemonize itself: 然后,该过程继续守护自己:

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

Our script loads rails before doing the daemonize step. 我们的脚本在执行守护进程之前先加载rails。 If this doesn't work, include how your script loads rails. 如果这不起作用,请包括脚本如何加载rails。

Try start working without monitor: 尝试在没有监视器的情况下开始工作:

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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM