Overview
This is a record of the code reading process for Ruby on Rails.
Preparation
- Create a new project with
rails new RailsCodeReading. - Add the following to the Gemfile:
gem 'pg'
gem 'pry-rails'
gem 'pry-doc'
gem 'pry-byebug'
gem 'byebug'
- Run
bundle config set path '.bundle'and then executebundle install.
Code Reading
Read the code up to the server execution part after executing the rails server command until Rails starts.
- rails/rails - railties/lib/rails/commands/server/server_command.rb#L132
- The actual server command
- rails/rails - railties/lib/rails/commands/server/server_command.rb#L32
- Server startup process
super()callsRackup::Server'sstart
- rails/rails - railties/lib/rails/rackup/server.rb#L8
- Requires
rackup/server
- Requires
- rack/rackup - lib/rackup/server.rb#L300
- rack/rackup - lib/rackup/server.rb#L341
server.runcalls the server startup process
- rack/rackup - lib/rackup/server.rb#L341
- puma/puma - lib/rack/handler/puma.rb#L67
- The server called by
server.rundepends on the server used by the application - If using Puma, this
runis called
- The server called by