Ruby守护进程无法启动。

3

我正在使用Ruby Daemons gem为我的Rails项目创建自定义守护进程。唯一的问题是,当我尝试启动守护进程ruby lib/daemons/test_ctl start时,它会失败并且无法启动。日志文件显示以下输出。

# Logfile created on Wed Oct 22 16:14:23 +0000 2008 by /  
*** below you find the most recent exception thrown, this will be likely (but not certainly) the exception that made the application exit abnormally \*\*\*  
# MissingSourceFile: no such file to load -- utf8proc_native  
*** below you find all exception objects found in memory, some of them may have been thrown in your application, others may just be in memory because they are standard exceptions ***  
# NoMemoryError: failed to allocate memory>  
# SystemStackError: stack level too deep>  
# fatal: exception reentered>  
# LoadError: no such file to load -- daemons>  
# LoadError: no such file to load -- active_support>  
# MissingSourceFile: no such file to load -- lib/string>  
# MissingSourceFile: no such file to load -- utf8proc_native>  

即使我从rails插件生成守护进程并尝试运行它,这种情况仍然会发生。有人知道如何解决这个问题吗?

2个回答

3

好的,我实际上找到了解决这个问题的答案。我需要在config/environment.rb中使用两个自定义文件。我使用了相对路径名,因为守护程序是在Rails主目录中执行的,所以找不到这两个文件。将它们改为绝对路径后,问题得到解决。


我通过在Daemons.run行之前添加以下行成功使其工作: $: << Dir.pwd 这将当前工作目录显式地添加到Ruby的包含路径中。由于某种原因,在使用daemons库时,这是必需的;包含路径看起来很好,但在我添加这个之前并没有起作用。 - duma
2
更新:我仍然遇到了包含错误。从使用Daemons.run到Daemons.run_proc修复了我的车。这是用这种方法创建守护进程脚本的方式:require 'rubygems' require 'daemons' pwd = Dir.pwd Daemons.run_proc('yourserver.rb') do Dir.chdir(pwd) exec "ruby yourserver.rb' end - duma
使用'require_relative'代替'require'同样有效。 - Alexander Smirnov

1

我刚刚花了30分钟尝试解决一个类似的错误,当我试图让守护进程插件工作时:

LoadError: no such file to load -- active_support

由于某些原因,它没有找到active_support库,尽管已经安装了(可能是因为我冻结了Rails)。 在我的情况下,解决这个问题的方法是在我的ctl文件中使用绝对路径来引用active_support(例如lib/daemons/mailer_ctl)。
我需要更改第5行:
   require 'active_support'

 require './vendor/rails/activesupport/lib/active_support.rb'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接