我在使workling守护程序正常工作时遇到问题。我跑的时候:
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将工作程序listen.rb作为守护程序加载。我没有在listen.rb中加载rails,而是更改了它,以便在workling_client中加载它,并且该过程顺利进行。因此,我无法在守护程序脚本中加载rails: - (
答案 0 :(得分:1)
您可以发布启动守护程序脚本的代码吗?我知道可以在守护进程脚本中加载rails,因为我们是为delayed_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。如果这不起作用,请包括脚本加载rails的方式。
答案 1 :(得分: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
}