Dear fellows, I have a subject about handling environmental variables on FastCGI. My solution is to modify Rails to suit FastCGI as same as CGI. Rails has the specification to be controlled with environmental variables, but on FastCGI, there is incompatibility about env. variables set by system (via FastCGI protocol). I found that applications that have same spec. merge FastCGI env. variables and process''s by themselves. Rails is not an user application but a middleware, so Rails should behave like that, I think. Then, my current way to avoid this problem is overriding FCGI::RecordBuffer#env to import ENV in dispatch.fcgi.> require File.dirname(__FILE__) + "/../config/environment" > require ''fcgi_handler'' > > class FCGI > class RecordBuffer > def env > h = {} > h.update(ENV) > @envs.each { |e| h.update(e.values) } > return h > end > end > end > > RailsFCGIHandler.process!I don''t think that Ruby-FCGI should not include this function because it must be just a protocol stack. Could you show me your opinion? Thank you for your reading. Sincerely, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> Then, my current way to avoid this problem is overriding > FCGI::RecordBuffer#env to import ENV in dispatch.fcgi. > > > require File.dirname(__FILE__) + "/../config/environment" > > require ''fcgi_handler'' > > > > class FCGI > > class RecordBuffer > > def env > > h = {} > > h.update(ENV) > > @envs.each { |e| h.update(e.values) } > > return h > > end > > end > > end > > > > RailsFCGIHandler.process! > > I don''t think that Ruby-FCGI should not include this function because > it must be just a protocol stack. > > Could you show me your opinion?Hi There, What particular problem have you hit that would require these changes? -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Hello Koziarski-san,> What particular problem have you hit that would require these changes?In the case of path based multiple projects on lighttpd + fastcgi. That needs additional configuration compared with apache, to modify AbstractRequest.relative_url_root. Someone set it at config/route.rb. Someone override AbstractRequest#relative_url_root to refer ENV originally referring @env built from CGI#env_table. Of course I should investigate to choose other platform, apache, mongrel or something else. But to install them on the user''s host, I need the reasonable reason to persuade. So I need the current conclusion about using lighttpd. (I''m sorry but I could not find it on the log.) Sincerely, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> So you''d modify the relative URL root while your application is > running? Or is this only used at startup?Only at startup. I''ve no need dynamic url (path) changing during running application. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
At 4:47 PM +1200 9/9/07, Michael Koziarski wrote:> > In the case of path based multiple projects on lighttpd + fastcgi. >> That needs additional configuration compared with apache, to modify >> AbstractRequest.relative_url_root. >> >> Someone set it at config/route.rb. >> Someone override AbstractRequest#relative_url_root to refer ENV >> originally referring @env built from CGI#env_table. > >So you''d modify the relative URL root while your application is >running? Or is this only used at startup?Perhaps the problem you describe is related to a problem I''ve worked around. In one project I''m serving multiple rails apps from one directory AND referring to them like this: http://host.com/app1 http://host.com/app2 Apache proxies to lighttpd which calls rails through fcgi. In config/environment.rb I have to include the following: RAILS_APPLICATION_PREFIX = ''app1'' # uncomment the next line if this application is served from a directory with other rails applications ActionController::AbstractRequest.relative_url_root = ''/'' + RAILS_APPLICATION_PREFIX Part of my lighttpd config for app1 looks like this: fastcgi.server = ( ".fcgi" => ( ( "bin-path" => basedir + "app1/public/dispatch.fcgi", "bin-environment" => ( "RAILS_ENV" => "production", "RAILS_RELATIVE_URL_ROOT" => "/app1" ) ))) I had thought setting the ENV constant RAILS_RELATIVE_URL_ROOT would serve to set ActionController::AbstractRequest.relative_url_root -- but that didn''t work. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Hello Bannasch-san,> I had thought setting the ENV constant RAILS_RELATIVE_URL_ROOT would serve to set ActionController::AbstractRequest.relative_url_root -- but that didn''t work.This is I said. On FastCGI process''s env. and each request''s env. are different. To merge them is responsibility of the application which wants to refer them equivalently. And a way to merge them on rails is overriding FCGI::RecordBuffer#env. #I can''t say that this is a FastCGI''s protocol bug because I am just a new comer to world of CGI.> RAILS_APPLICATION_PREFIX = ''app1'' > # uncomment the next line if this application is served from a directory with other rails applications > ActionController::AbstractRequest.relative_url_root = ''/'' + RAILS_APPLICATION_PREFIXOops, I''ve never met these lines. Is this a recent grammer of rails? Sincerely, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
At 9:23 PM -0700 9/9/07, oshida wrote:> > RAILS_APPLICATION_PREFIX = ''app1'' >> # uncomment the next line if this application is served from a directory with other rails applications > > ActionController::AbstractRequest.relative_url_root = ''/'' + RAILS_APPLICATION_PREFIX > >Oops, I''ve never met these lines. >Is this a recent grammer of rails?No , it is code I added. When I deploy multiple rails apps served from subdirectories I set my own constant named: RAILS_APPLICATION_PREFIX in config/environment.rb for later use. I set this constant equal to the name of the directory where the rails app is located. One use is for setting ActionController::AbstractRequest.relative_url_root. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> No , it is code I added.OK I see. I found the entry on rails wiki: http://wiki.rubyonrails.org/rails/pages/HowToInstallApplicationsInSubdirectories These way need static code modification but I want not to do so. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---