rails启动过程
来源:互联网 发布:万方等数据库 编辑:程序博客网 时间:2024/06/15 19:57
2010-10-01 09:23:40
标签:休闲 rails启动过程 职场
boot.rb
- def boot!
- unless booted?
- preinitialize
- pick_boot.run
- end
- end
def boot! unless booted? preinitialize pick_boot.run endendhttp://yudionrails.com/2008/1/7/what-s-new-in-edge-rails-pre-environment-load-hook
initialize.rb
- class Boot
- def run
- load_initializer
- Rails::Initializer.run(:set_load_path)
- end
- end
class Boot def run load_initializer Rails::Initializer.run(:set_load_path) endend
- class VendorBoot < Boot
- def load_initializer
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
- end
- end
class VendorBoot < Boot def load_initializer require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" endend
- class GemBoot < Boot
- def load_initializer
- self.class.load_rubygems
- load_rails_gem
- require 'initializer'
- end
- ...
- end
class GemBoot < Boot def load_initializer self.class.load_rubygems load_rails_gem require 'initializer' end ...end配置名(accessor名)具体描述frameworks会被载入的Rails框架组件列表,会包括action_controller,action_view等load_paths附加的load路径列表,app/controller;app/models等Rails项目下的目录load_once_pathsRails只会load一次的目录,似乎目前版本的Rails未用到这个参数log_path日志文件的路径,根据目前的环境(development,test,production)决定log_levelRails日志器的日志级别(info,debug)view_pathview的目录路径,默认路径是app/view了controller_pathscontroller的目录路径,默认路径是app/controllercache_classes是否对类进行缓存。目前未使用(一直是false)whiny_nilstrue/false,当设置为true的话,当你在Rails中调用一个nil方法的时候,将会得到警告plugins载入的插件列表,默认为空plugin_paths插件路径,默认是RAILS_ROOT/vendor/plugins目录plugin_locators插件的定位器,默认是Plugin::FileSystemLocatorplugin_loader插件的载入器,默认是Plugin::Loaderdatabase_configuration_file数据库配置文件,默认位于RAILS_ROOT/config/database.yml
- def self.run(command = :process, configuration = Configuration.new)
- yield configuration if block_given?
- initializer = new configuration
- initializer.send(command)
- initializer
- end
def self.run(command = :process, configuration = Configuration.new) yield configuration if block_given? initializer = new configuration initializer.send(command) initializerend
- def default_frameworks
- [ :active_record, :action_controller, :action_view, :action_mailer, :active_resource ]
- end
def default_frameworks [ :active_record, :action_controller, :action_view, :action_mailer, :active_resource ]end
- def default_controller_paths
- paths = [File.join(root_path, 'app', 'controllers')]
- paths.concat builtin_directories
- paths
- end
def default_controller_paths paths = [File.join(root_path, 'app', 'controllers')] paths.concat builtin_directories pathsend
- Rails::Initializer.run do |config|
- config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
- config.plugins = [ :exception_notification, :ssl_requirement, :all ]
- ...
- end
Rails::Initializer.run do |config| config.frameworks -= [ :active_record, :active_resource, :action_mailer ] config.plugins = [ :exception_notification, :ssl_requirement, :all ] ...end
- require File.dirname(__FILE__) + '/../config/boot'
- require 'commands/server'
require File.dirname(__FILE__) + '/../config/boot'require 'commands/server'
server.rb
- require 'active_support'
require 'active_support'
- begin
- require_library_or_gem 'fcgi'
- rescue Exception
- # FCGI not available
- end
- begin
- require_library_or_gem 'mongrel'
- rescue Exception
- # Mongrel not available
- end
begin require_library_or_gem 'fcgi'rescue Exception # FCGI not availableendbegin require_library_or_gem 'mongrel'rescue Exception # Mongrel not availableend
- require "commands/servers/#{server}"
require "commands/servers/#{server}"
webrick.rb
- require 'webrick'
- require RAILS_ROOT + "/config/environment"
- require 'webrick_server'
- DispatchServlet.dispatch(OPTIONS)
require 'webrick' require RAILS_ROOT + "/config/environment" require 'webrick_server' DispatchServlet.dispatch(OPTIONS)
environment.rb
webrick_server.rb
- class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
- # Start the WEBrick server with the given options, mounting the
- # DispatchServlet at <tt>/</tt>.
- def self.dispatch(options = {})
- Socket.do_not_reverse_lookup = true # patch for OS X
- params = { :Port => options[:port].to_i,
- :ServerType => options[:server_type],
- :BindAddress => options[:ip] }
- params[:MimeTypes] = options[:mime_types] if options[:mime_types]
- server = WEBrick::HTTPServer.new(params)
- server.mount('/', DispatchServlet, options)
- trap("INT") { server.shutdown }
- server.start
- end
- end
class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet # Start the WEBrick server with the given options, mounting the # DispatchServlet at <tt>/</tt>. def self.dispatch(options = {}) Socket.do_not_reverse_lookup = true # patch for OS X params = { :Port => options[:port].to_i, :ServerType => options[:server_type], :BindAddress => options[:ip] } params[:MimeTypes] = options[:mime_types] if options[:mime_types] server = WEBrick::HTTPServer.new(params) server.mount('/', DispatchServlet, options) trap("INT") { server.shutdown } server.start endend
0 0
- rails启动过程
- rails启动过程(一)代码流程概述
- rails启动过程(二)初始化及initializer
- Rails console 无法启动
- Rails的启动
- ruby rails server启动
- rails的初始化过程
- ruby & rails 安装过程叙述
- The Rails 4 Way -- 读书笔记--rails 是如何启动的
- ubuntu 下 ruby on rails rails server 服务启动失败
- 启动过程
- 启动过程
- 启动过程
- Rails启动时sqlite3.dll is missing
- Eclipse开始启动Rails的开篇
- 用mongrel + apache启动rails应用
- 介绍rails的启动 安装的网站
- 诗歌railsp之Rails的启动
- asp/aspx/htm和html的区别
- JSTL自定义标签二SimpleTagSupport(一)
- HDU 1556 Color the ball 线段树
- GCJ 2008 Round 1A Minimum Scalar Product
- 291计算机毕业设计
- rails启动过程
- UITableView 系列之自定义 UITableViewCell
- 按单词反转字符串
- 黑马程序员---选择排序 冒泡排序
- Codeforces Round #234 (Div. 2)
- github应用小记(LINUX)
- Ubuntu 12.04下解决Rhythmbox Music Player乱码问题
- 转:sudoers文件
- c# 多线程委托带参数传递