Application 2024-09-02

Ruby on Rails Code Reading Part 1 - Rails Startup

Trace Rails startup sequence from command invocation through Rackup, Puma server initialization, and request handling flow.

Read in: ja
Ruby on Rails Code Reading Part 1 - Rails Startup

Overview

This is a record of the code reading process for Ruby on Rails.

Preparation

  1. Create a new project with rails new RailsCodeReading.
  2. Add the following to the Gemfile:
gem 'pg'
gem 'pry-rails'
gem 'pry-doc'
gem 'pry-byebug'
gem 'byebug'
  1. Run bundle config set path '.bundle' and then execute bundle install.

Code Reading

Read the code up to the server execution part after executing the rails server command until Rails starts.

  1. rails/rails - railties/lib/rails/commands/server/server_command.rb#L132
  2. rails/rails - railties/lib/rails/rackup/server.rb#L8
    • Requires rackup/server
  3. rack/rackup - lib/rackup/server.rb#L300
  4. puma/puma - lib/rack/handler/puma.rb#L67
    • The server called by server.run depends on the server used by the application
    • If using Puma, this run is called

References

Tags: Ruby Ruby on Rails
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles