Rails 守护进程未启动
我有 Rails 3.0.3 项目,我尝试通过以下步骤创建守护进程:
http://railscasts。 com/episodes/129-custom-daemon
我已经安装了 gem 守护进程
sudo gem 安装守护进程
然后我安装了 daemon_generator
然后创建守护进程
rails 生成守护进程 game_processor
当我尝试运行守护进程时
./lib/daemons/game_processor_ctl 启动
我收到错误:
./lib/daemons/game_processor_ctl:2:in `require': 没有要加载的文件 -- rubygems (LoadError) 来自./lib/daemons/game_processor_ctl:2
守护进程代码:
#!/usr/bin/env ruby
需要“rubygems”
需要“守护进程”
需要“yaml”
需要“erb”
gem 'activesupport', '>=3.0.0.beta4' 需要“active_support”
# 由于某种原因,ActiveSupport 3.0.0 无法加载。 # 现在直接加载需要的扩展。 需要“active_support/core_ext/object” 需要“active_support/core_ext/hash”
选项 = YAML.load( ERB.new( IO. 读取( 文件.dirname(FILE) + "/../../config/daemons.yml" )).result).with_in Different_access
选项[:dir_mode] = 选项[:dir_mode].to_sym
Daemons.run File.dirname(FILE) + "/game_processor.rb", 选项
那么,出了什么问题?为什么它在尝试需要红宝石时会死掉?
I have Rails 3.0.3 project and I trying to create daemon by this steps:
http://railscasts.com/episodes/129-custom-daemon
I've installed gem daemons
sudo gem install daemons
Then I've install daemon_generator
rails plugin install https://github.com/dougal/daemon_generator.git
Then created daemon
rails generate daemon game_processor
When I try to run daemon
./lib/daemons/game_processor_ctl start
I got error:
./lib/daemons/game_processor_ctl:2:in `require': no such file to load -- rubygems (LoadError)
from ./lib/daemons/game_processor_ctl:2
Code of daemon:
#!/usr/bin/env ruby
require 'rubygems'
require "daemons"
require 'yaml'
require 'erb'
gem 'activesupport', '>=3.0.0.beta4'
require 'active_support'# For some reason, ActiveSupport 3.0.0 doesn't load.
# Load needed extension directly for now.
require "active_support/core_ext/object"
require "active_support/core_ext/hash"options = YAML.load(
ERB.new(
IO.read(
File.dirname(FILE) + "/../../config/daemons.yml"
)).result).with_indifferent_accessoptions[:dir_mode] = options[:dir_mode].to_sym
Daemons.run File.dirname(FILE) + "/game_processor.rb", options
So, What's wrong? Why it dies, when trying to require rubygems?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的是 Windows 还是 *nix 系统 - 在 Windows 上,您应该使用
ruby game_processor.rb start
而不是 _ctl。另外,当您将它与 Rails 一起使用时,我认为 Rails 服务器也应该以所需模式启动,以使守护进程正常运行。
Are you on Windows or *nix system - on Windows you should use
ruby game_processor.rb start
instead of _ctl.Also as you are using it with Rails - then i think Rails server should be started in required mode as well to make Daemon run properly.