From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.229.226.196 with SMTP id ix4cs96304qcb; Wed, 28 Dec 2011 20:47:33 -0800 (PST) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncCJD_vfqXERDh4e_3BBoEaoHAZg@googlegroups.com designates 10.224.10.9 as permitted sender) client-ip=10.224.10.9; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncCJD_vfqXERDh4e_3BBoEaoHAZg@googlegroups.com designates 10.224.10.9 as permitted sender) smtp.mail=rack-devel+bncCJD_vfqXERDh4e_3BBoEaoHAZg@googlegroups.com; dkim=pass header.i=rack-devel+bncCJD_vfqXERDh4e_3BBoEaoHAZg@googlegroups.com Received: from mr.google.com ([10.224.10.9]) by 10.224.10.9 with SMTP id n9mr22791501qan.4.1325134051581 (num_hops = 1); Wed, 28 Dec 2011 20:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:mime-version:date:in-reply-to:references:user-agent :x-http-useragent:message-id:subject:from:to:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type :content-transfer-encoding; bh=Ot2vehM5ruV5uNNSzRmttRs5FszfWE3fFqNuCi0FUFc=; b=zhB5Se3+JiAEmQEwhX9oBdeCiC0Q5DTnBXSx2a7GYOgIoTqM3URZt4bDhZ8UDyuY5L ch5pkaZiaYJlQJD9l5t6AtDZBfbtDlHrUQsbuH1ddLc/yRKM6N6rbMtRE25PGs8smHSv hszWQ8+BjSHa3uw/IJg2CKx/AKpgp5n/S+f6c= Received: by 10.224.10.9 with SMTP id n9mr7106185qan.4.1325134049117; Wed, 28 Dec 2011 20:47:29 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.224.96.15 with SMTP id f15ls27271404qan.4.gmail; Wed, 28 Dec 2011 20:47:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.116.18 with SMTP id k18mr2347514qaq.17.1325134048547; Wed, 28 Dec 2011 20:47:28 -0800 (PST) Received: by cs7g2000vbb.googlegroups.com with HTTP; Wed, 28 Dec 2011 20:47:28 -0800 (PST) Date: Wed, 28 Dec 2011 20:47:28 -0800 (PST) In-Reply-To: References: <54F669AE-14FD-425A-B6CE-BBC4D893D5ED@gmail.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7,gzip(gfe) Message-ID: Subject: Re: Rack Application Initializes On Every Request From: Frank Ficnar To: Rack Development X-Original-Sender: frank.ficnar@gmail.com X-Original-Authentication-Results: ls.google.com; spf=pass (google.com: domain of frank.ficnar@gmail.com designates internal as permitted sender) smtp.mail=frank.ficnar@gmail.com; dkim=pass header.i=@gmail.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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=A0pm, Frank Ficnar 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 > =A0 run Rack::File.new(File.join(RubyApp::ROOT, %w[resources > favicon.ico])) > end > > map '/ruby_app/resources' do > =A0 run Rack::File.new(File.join(RubyApp::ROOT, %w[resources])) > end > > map '/' do > =A0 use RubyApp::Rack::Application > =A0 run RubyApp::Rack::Route.new > end > > ... where RubyApp is my middleware/application. > > During development the server is started via ... > > Rack::Server.start(:config =3D> '(path to config.ru)') > > It's the RubyApp::Rack::Application class that I've observed being > initialized on every request. =A0I haven't checked but I suspect the > RubyApp::Rack::Route class is as well. > > Thanks for your help. > > Frank > > On Dec 28, 1:35=A0pm, James Tucker 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, t= hen it's likely you forgot to call #to_app on the Builder instance before p= assing 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 t= o > > > my Rack application (non-Rails)? > > > > Rack' 1.3.5 didn't do this ... it started with the 1.4.0 update. > > > > Frank