ruby-on-rails – 带Rails的自定义守护程序3
发布时间:2020-12-16 20:25:39 所属栏目:百科 来源:网络整理
导读:我正在尝试创建加载Rails环境的自定义守护程序. 我的环境如下: 红宝石1.9.2-P180 导轨3.0.5 我做了以下: – 安装守护进程宝石 – 在这里找到的安装的daemon_generator插件: https://github.com/dougal/daemon_generator – 生成守护进程:rails生成守护进
我正在尝试创建加载Rails环境的自定义守护程序.
我的环境如下: 红宝石1.9.2-P180 导轨3.0.5 我做了以下: – 安装守护进程宝石 – 在这里找到的安装的daemon_generator插件: – 生成守护进程:rails生成守护进程监听器 所有这一切都很好.当我运行守护进程时,它可以运行. 但是,一旦我尝试访问一个活动的记录对象,就像试图检索一个用户一样,它会爆炸. *** below you find the most recent exception thrown,this will be likely (but not certainly) the exception that made the application exit abnormally *** #<NameError: method `recognize' not defined in Rack::Mount::RouteSet> *** 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> #<NoMethodError: undefined method `eq' for nil:NilClass> #<NameError: method `recognize' not defined in Rack::Mount::RouteSet> 关于如何创建加载Rails 3.0.5的守护进程的任何想法? 解决方法
我喜欢滚动我自己的rails守护进程控制器.这是一个简单的例子,适用于大多数情况:
脚本/守护 #!/usr/bin/env ruby require 'rubygems' require 'daemons' ENV["APP_ROOT"] ||= File.expand_path("#{File.dirname(__FILE__)}/..") ENV["RAILS_ENV_PATH"] ||= "#{ENV["APP_ROOT"]}/config/environment.rb" script = "#{ENV["APP_ROOT"]}/daemons/#{ARGV[1]}" Daemons.run(script,dir_mode: :normal,dir: "#{ENV["APP_ROOT"]}/tmp/pids") 守护进程/ your_daemon_script.rb require ENV["RAILS_ENV_PATH"] loop { ... your code ... } 您可以使用以下命令来控制您的deamons: script/daemon run your_daemon_script.rb script/daemon start your_daemon_script.rb script/daemon stop your_daemon_script.rb 这使我能够轻松添加新的守护进程,如果需要,我可以轻松地在每个脚本中加载rails. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |