Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Rack Application Initializes On Every Request
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Frank Ficnar  
View profile  
 More options Dec 28 2011, 10:43 am
From: Frank Ficnar <frank.fic...@gmail.com>
Date: Wed, 28 Dec 2011 07:43:50 -0800 (PST)
Local: Wed, Dec 28 2011 10:43 am
Subject: Rack Application Initializes On Every Request
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Tucker  
View profile  
 More options Dec 28 2011, 1:35 pm
From: James Tucker <jftuc...@gmail.com>
Date: Wed, 28 Dec 2011 14:35:27 -0400
Local: Wed, Dec 28 2011 1:35 pm
Subject: Re: Rack Application Initializes On Every Request
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frank Ficnar  
View profile  
 More options Dec 28 2011, 2:38 pm
From: Frank Ficnar <frank.fic...@gmail.com>
Date: Wed, 28 Dec 2011 11:38:12 -0800 (PST)
Local: Wed, Dec 28 2011 2:38 pm
Subject: Re: Rack Application Initializes On Every Request
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frank Ficnar  
View profile  
 More options Dec 28 2011, 11:47 pm
From: Frank Ficnar <frank.fic...@gmail.com>
Date: Wed, 28 Dec 2011 20:47:28 -0800 (PST)
Local: Wed, Dec 28 2011 11:47 pm
Subject: Re: Rack Application Initializes On Every Request
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »