[Catalyst] FastCGI ENV issue

Andy Grundman andy at hybridized.org
Mon Nov 14 20:27:34 CET 2005


I've run into an issue with %ENV under lighttpd + FastCGI.  I believe 
the same issue occurs using Apache.

The issue is that the initial %ENV that exists when you first start your 
app, including any variables you set in BEGIN blocks, is clobbered on 
every request.  Each request gets a new %ENV from the web server.

I had a problem with Oracle connections because ORACLE_HOME was not 
being set on each request, only on startup.

I came up with a quick fix, can anyone see any issues with this?

     # save initial ENV state during startup
     my %startup_ENV = %ENV;

     ....

     while ( $request->Accept >= 0 ) {

         # merge initial ENV with request ENV
         %ENV = ( %startup_ENV, %{ $request->GetEnvironment() } );

         $class->handle_request;
     }

-Andy



More information about the Catalyst mailing list