Skip to content

Initialization

Lars Olsson edited this page Dec 6, 2015 · 1 revision

Initialization

This is a high level overview of how a Racket application is initialized. This page i a work in progress, Racket has changed its Initialization process several times already. However, from version 0.4 onward, I am planning on having a more stable initialization process, so if you are use a Racket version newer than that you may rely on the information on this page being accurate.

The following steps are performed whenever a Racket application is initialized

  1. Racket is invoked using either Racket::Application#default or Racket::Application#using
  2. Racket::Application#init is the main entry point for Racket::Application. It takes one parameter, settings, which is a hash containing all configuration that is needed for starting the Racket application.
  3. A Racket::Settings::Application object is created to hold settings for the current application.
  4. Racket::Application#application is called to make sure all middleware and all default helper modules are loaded. After this step, Racket will be able to find all plugins and helpers without requiring them again.
  5. Racket::Application#setup_static_server is called. If the configuration option :public_dir is a string, this step will set up a Rack::File handler for the public directory, otherwise this step will do nothing.
  6. A Racket::Router object is created to hold routes in the application.
  7. Controllers are loaded by calling Racket::Application#load_controllers. This involves three steps: 1. Controller class is loaded. 2. Controller class is added to the list of routes held by the router object. 3. Helpers (both default and specific to the controller) are included in the controller class.

Clone this wiki locally