Forum: Ruby on Rails Rails Initialization

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Lee (Guest)
on 2007-05-30 05:13
(Received via mailing list)
I have labored under the (possibly naive) misconception that a Rails
app initialized and loaded on every request.  Now I've found hints
that the core application loads and stays available for later
requests?  How is this possible?  I thought that the Ruby interpretter
loads everything into its own little happy process.  Does Rails wait
around for requests on a port or something to keep it connected to the
webserver?

I'm working on understanding Rails Initialization and the full process
of the framework.

Thanks guys!

Lee Hericks
MichaelLatta (Guest)
on 2007-05-30 06:01
(Received via mailing list)
The Mongrel or WEBrick web servers do in fact stay running between
requests.  In development model WEBrick will reload modified files.  I
have yet to determine if it provides any ordering of those files or
just reloads the files on top of whatever was there.  So far I have
not seen any indication that patches from one class are lost when
reloading another file so it is not simply just reloading files on top
of the current version.

Michael
Lee (Guest)
on 2007-05-30 07:02
(Received via mailing list)
A first request comes in.  The rails app hasn't been loaded yet.

The dispatcher sees that nothing is defined, so it loads
environment.rb

environment.rb loads boot.rb

boot.rb sees that the initializer is not present, so it loads
initialize.rb

The whole framework boots up to life.

Routing processes the request and a response is sent back to browser.

NOW...how is that Ruby environment persisted and able to handle the
next request sent to the web server?  Assume Lighty.  Lighty gets a
request and maybe passes it off to Mongrel.  Mongrel is written in
Ruby and mongrels keep running.  Is that why the next request given to
the mongrel loads the dispatcher, which sees RAILS_ROOT and skips
loading the environment, and processes the request?

If so, what does that mean if you are not using Mongrel?  What if you
are simply using lighttpd?  What keeps running the Rails-loaded Ruby
environment?

Lee Hericks
This topic is locked and can not be replied to.