[Rt-devel] Experimental FastCGI-PM

Matt Knopp mhat at netlag.com
Fri May 14 17:22:17 EDT 2004

Here's the code I mentioned earlier today. You'll need yet another module
from CPAN: 


Install, blah blah. 

The supplied patch should give you some general ideas. You will probably 
need to edit the patch some to fit your needs [paths, etc]. 

Also, you will need to add the following to your RT_SiteConfig.pm: 

  Set($FCGIProcesses,         6);

Oh and if you're running in a truly memory starved environment you might
want to look at the last few lines of the request loop; there is a tiny
bit of code there to cause the fcgi processes to exit after a defined 
number of requests. If you chose to turn this on you'll need to also add
the following to your RT_SiteConfig.pm: 

  Set($FCGIRequestCounter,    0);
  Set($FCGIMaxRequests,    1000);

Set FCGIMaxRequests to whatever seems like a reasonable value to you. 
Most this helps work around the tendency for RT processes to get very 

-------------- next part --------------
--- ../src/rt-3.0.10/bin/mason_handler.fcgi	2004-04-01 20:09:55.000000000 -0600
+++ mason_handler.fcgi-p	2004-05-14 15:58:19.000000000 -0500
@@ -23,9 +23,11 @@
+use lib '/opt/coreadm/lib/perl5';
+use lib '/opt/coreadm/lib/perl5/site_perl';
 use strict;
 use File::Basename;
-require ('/opt/vws/webmail1/rt/bin/webmux.pl');
+require ('/opt/webapp/rt/bin/webmux.pl');
 my $h = &RT::Interface::Web::NewCGIHandler(@RT::MasonParameters);
@@ -34,8 +36,16 @@
+# FCGI Process Manager 
+use FCGI::ProcManager;
+my $procman = new FCGI::ProcManager({ n_processes => RT::FCGIProcesses });
+   $procman->pm_manage(); 
 # Response loop
 while ( my $cgi = CGI::Fast->new ) {
+    $procman->pm_pre_dispatch(); 
     # the whole point of fastcgi requires the env to get reset here..
     # So we must squash it again
     $ENV{'PATH'}   = '/bin:/usr/bin';
@@ -62,6 +72,8 @@
         $RT::Logger->crit("Transaction not committed. Usually indicates a software fault. Data loss may have occurred") ;
+    $procman->pm_post_dispatch();
+    #exit(0) if ++$RT::FCGIRequestCounter > $RT::FCGIMaxRequests;

More information about the Rt-devel mailing list