* Rack Application Initializes On Every Request
@ 2011-12-28 15:43 Frank Ficnar
2011-12-28 18:35 ` James Tucker
0 siblings, 1 reply; 4+ messages in thread
From: Frank Ficnar @ 2011-12-28 15:43 UTC (permalink / raw)
To: Rack Development
Is it normal that my 'initialize' method is called on every request to
my Rack application (non-Rails)?
Rack' 1.3.5 didn't do this ... it started with the 1.4.0 update.
Frank
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Rack Application Initializes On Every Request
2011-12-28 15:43 Rack Application Initializes On Every Request Frank Ficnar
@ 2011-12-28 18:35 ` James Tucker
2011-12-28 19:38 ` Frank Ficnar
0 siblings, 1 reply; 4+ messages in thread
From: James Tucker @ 2011-12-28 18:35 UTC (permalink / raw)
To: rack-devel
Can you provide some more information?
Rack doesn't instantiate anything itself.
If you're using Rack::Builder, and you're talking about a middleware, then it's likely you forgot to call #to_app on the Builder instance before passing it to the handler.
On Dec 28, 2011, at 11:43 AM, Frank Ficnar wrote:
> Is it normal that my 'initialize' method is called on every request to
> my Rack application (non-Rails)?
>
> Rack' 1.3.5 didn't do this ... it started with the 1.4.0 update.
>
> Frank
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Rack Application Initializes On Every Request
2011-12-28 18:35 ` James Tucker
@ 2011-12-28 19:38 ` Frank Ficnar
2011-12-29 4:47 ` Frank Ficnar
0 siblings, 1 reply; 4+ messages in thread
From: Frank Ficnar @ 2011-12-28 19:38 UTC (permalink / raw)
To: Rack Development
I'm not using Rack::Builder directly ... unless it's being used behind
the scenes.
I've got a config..ru as follows ...
#\ --warn --port 8008 --pid ./rack.pid
require 'rubygems'
require 'bundler/setup'
require 'rack'
require 'ruby_app/rack/application'
require 'ruby_app/rack/route'
require 'ruby_app/version'
use Rack::ShowExceptions
use Rack::Session::Pool
use Rack::Reloader
use Rack::ContentLength
map '/favicon.ico' do
run Rack::File.new(File.join(RubyApp::ROOT, %w[resources
favicon.ico]))
end
map '/ruby_app/resources' do
run Rack::File.new(File.join(RubyApp::ROOT, %w[resources]))
end
map '/' do
use RubyApp::Rack::Application
run RubyApp::Rack::Route.new
end
... where RubyApp is my middleware/application.
During development the server is started via ...
Rack::Server.start(:config => '(path to config.ru)')
It's the RubyApp::Rack::Application class that I've observed being
initialized on every request. I haven't checked but I suspect the
RubyApp::Rack::Route class is as well.
Thanks for your help.
Frank
On Dec 28, 1:35 pm, James Tucker <jftuc...@gmail.com> wrote:
> Can you provide some more information?
>
> Rack doesn't instantiate anything itself.
>
> If you're using Rack::Builder, and you're talking about a middleware, then it's likely you forgot to call #to_app on the Builder instance before passing it to the handler.
>
> On Dec 28, 2011, at 11:43 AM, Frank Ficnar wrote:
>
>
>
>
>
>
>
> > Is it normal that my 'initialize' method is called on every request to
> > my Rack application (non-Rails)?
>
> > Rack' 1.3.5 didn't do this ... it started with the 1.4.0 update.
>
> > Frank
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Rack Application Initializes On Every Request
2011-12-28 19:38 ` Frank Ficnar
@ 2011-12-29 4:47 ` Frank Ficnar
0 siblings, 0 replies; 4+ messages in thread
From: Frank Ficnar @ 2011-12-29 4:47 UTC (permalink / raw)
To: Rack Development
I was doing some hunting and found that if I removed the map blocks
and replaced the last '/' block with the 'use' and 'run' statements
only, initialization of the RubyApp::Rack::Application class DID NOT
happen per-request. It happened once at startup (as expected) only.
If I put the map blocks back in then initialization of the
RubyApp::Rack::Application class DID happen per-request and DID NOT
happen at startup.
Am I doing something wrong with the map blocks?
On Dec 28, 2:38 pm, Frank Ficnar <frank.fic...@gmail.com> wrote:
> I'm not using Rack::Builder directly ... unless it's being used behind
> the scenes.
>
> I've got a config..ru as follows ...
>
> #\ --warn --port 8008 --pid ./rack.pid
> require 'rubygems'
> require 'bundler/setup'
>
> require 'rack'
>
> require 'ruby_app/rack/application'
> require 'ruby_app/rack/route'
> require 'ruby_app/version'
>
> use Rack::ShowExceptions
> use Rack::Session::Pool
> use Rack::Reloader
> use Rack::ContentLength
>
> map '/favicon.ico' do
> run Rack::File.new(File.join(RubyApp::ROOT, %w[resources
> favicon.ico]))
> end
>
> map '/ruby_app/resources' do
> run Rack::File.new(File.join(RubyApp::ROOT, %w[resources]))
> end
>
> map '/' do
> use RubyApp::Rack::Application
> run RubyApp::Rack::Route.new
> end
>
> ... where RubyApp is my middleware/application.
>
> During development the server is started via ...
>
> Rack::Server.start(:config => '(path to config.ru)')
>
> It's the RubyApp::Rack::Application class that I've observed being
> initialized on every request. I haven't checked but I suspect the
> RubyApp::Rack::Route class is as well.
>
> Thanks for your help.
>
> Frank
>
> On Dec 28, 1:35 pm, James Tucker <jftuc...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Can you provide some more information?
>
> > Rack doesn't instantiate anything itself.
>
> > If you're using Rack::Builder, and you're talking about a middleware, then it's likely you forgot to call #to_app on the Builder instance before passing it to the handler.
>
> > On Dec 28, 2011, at 11:43 AM, Frank Ficnar wrote:
>
> > > Is it normal that my 'initialize' method is called on every request to
> > > my Rack application (non-Rails)?
>
> > > Rack' 1.3.5 didn't do this ... it started with the 1.4.0 update.
>
> > > Frank
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-29 4:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-28 15:43 Rack Application Initializes On Every Request Frank Ficnar
2011-12-28 18:35 ` James Tucker
2011-12-28 19:38 ` Frank Ficnar
2011-12-29 4:47 ` Frank Ficnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).