[Rt-commit] rt branch, external_fastcgi, updated. rt-3.8.6-133-gdaee160

Ruslan Zakirov ruz at bestpractical.com
Fri Dec 4 00:38:36 EST 2009


The branch, external_fastcgi has been updated
       via  daee1605f241578a7cdc6e3ac7a0068de65fb61f (commit)
       via  a79f4ca97b416d4c3560981df5d01c029a5319d8 (commit)
       via  035984441ce761d9ac652f207823946bfa2b7f58 (commit)
       via  1f6c85d7a87757635a2c40ca12ede106edc0df10 (commit)
       via  9b6cb6aa2ca22a189566b41b6d34cd3c03927969 (commit)
       via  d2ea884f8adeaecf50c2914912cfa111d814c337 (commit)
       via  69a647bbc54ce4b75fde2703229ff37792f9a870 (commit)
       via  f59c0c6946972029cfbaad22cdb8cad90ad527a1 (commit)
       via  d5decef87e2db7037ae6895716a838cd2670c872 (commit)
       via  d32d3fdacc0c627b1910ab7686cdb1dae49ed9ac (commit)
       via  dffcea9b77ddd7e0e9951f6837905806f32501a6 (commit)
       via  e0253a37395cdc4b17c2f3ff00787be90b713bb4 (commit)
      from  9031c9822980b842125f3e989660bf037fc4395c (commit)

Summary of changes:
 bin/{mason_handler.fcgi.in => fastcgi_server.in} |   41 ++++---
 bin/mason_handler.fcgi.in                        |   25 ++--
 bin/mason_handler.scgi.in                        |    7 +-
 bin/webmux.pl.in                                 |  151 +++++++++++-----------
 lib/RT.pm.in                                     |    3 +
 lib/RT/Crypt/GnuPG.pm                            |   26 ++--
 lib/RT/Test.pm                                   |   34 +++---
 lib/RT/Util.pm                                   |   36 +++++
 t/data/configs/apache2.2+fastcgi.conf.in         |    4 +-
 t/data/configs/apache2.2+mod_perl.conf.in        |    1 +
 10 files changed, 180 insertions(+), 148 deletions(-)
 copy bin/{mason_handler.fcgi.in => fastcgi_server.in} (79%)
 mode change 100755 => 100644

- Log -----------------------------------------------------------------
commit e0253a37395cdc4b17c2f3ff00787be90b713bb4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 9 02:10:35 2009 +0400

    factor our InitSignalHandlers

diff --git a/lib/RT.pm.in b/lib/RT.pm.in
index f0e56e8..9ada958 100755
--- a/lib/RT.pm.in
+++ b/lib/RT.pm.in
@@ -350,7 +350,10 @@ sub InitLogging {
                          ));
         }
     }
+    InitSignalHandlers();
+}
 
+sub InitSignalHandlers {
 
 # Signal handlers
 ## This is the default handling of warnings and die'ings in the code

commit dffcea9b77ddd7e0e9951f6837905806f32501a6
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 9 02:11:40 2009 +0400

    60 seconds is too much for server startup

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 34e5fae..301785e 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1069,7 +1069,7 @@ sub start_apache_server {
 
     $self->fork_exec($info{'executable'}, '-f', $tmp{'config'}{'apache'});
     my $pid = do {
-        my $tries = 60;
+        my $tries = 10;
         while ( !-e $pid_fn ) {
             $tries--;
             last unless $tries;

commit d32d3fdacc0c627b1910ab7686cdb1dae49ed9ac
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 9 02:12:50 2009 +0400

    rewrite and refactor webmux.pl

diff --git a/bin/webmux.pl.in b/bin/webmux.pl.in
index 7e61b27..1e62f52 100755
--- a/bin/webmux.pl.in
+++ b/bin/webmux.pl.in
@@ -48,20 +48,62 @@
 # END BPS TAGGED BLOCK }}}
 use strict;
 
+package HTML::Mason::Commands;
+our %session;
+
+package RT::Mason;
+
+our ($Nobody, $SystemUser, $Handler, $r);
+
+sub handler {
+    ($r) = @_;
+
+    local $SIG{__WARN__};
+    local $SIG{__DIE__};
+    RT::InitSignalHandlers();
+
+    if ($r->content_type =~ m/^httpd\b.*\bdirectory/i) {
+        use File::Spec::Unix;
+        # Our DirectoryIndex is always index.html, regardless of httpd settings
+        $r->filename( File::Spec::Unix->catfile( $r->filename, 'index.html' ) );
+    }
+
+    Module::Refresh->refresh if RT->Config->Get('DevelMode');
+
+    RT::ConnectToDatabase();
+
+    my (%session, $status);
+    {
+        local $@;
+        $status = eval { $Handler->handle_request($r) };
+        $RT::Logger->crit( $@ ) if $@;
+    }
+    undef %session;
+
+    RT::Interface::Web::Handler->CleanupRequest();
+
+    return $status;
+}
+
+package main;
+
+# check mod_perl version if it's mod_perl
+BEGIN {
+    die "RT does not support mod_perl 1.99. Please upgrade to mod_perl 2.0"
+        if $ENV{'MOD_PERL'}
+        and $ENV{'MOD_PERL'} =~ m{mod_perl/(?:1\.9)};
+}
+
 BEGIN {
-    $ENV{'PATH'}   = '/bin:/usr/bin';                     # or whatever you need
+    $ENV{'PATH'}   = '/bin:/usr/bin'; # or whatever you need
     $ENV{'CDPATH'} = '' if defined $ENV{'CDPATH'};
     $ENV{'SHELL'}  = '/bin/sh' if defined $ENV{'SHELL'};
     $ENV{'ENV'}    = '' if defined $ENV{'ENV'};
     $ENV{'IFS'}    = '' if defined $ENV{'IFS'};
 
-    use CGI qw(-private_tempfiles);    #bring this in before mason, to make sure we
-                                   #set private_tempfiles
-
-    die "RT does not support mod_perl 1.99. Please upgrade to mod_perl 2.0"
-      if $ENV{'MOD_PERL'}
-      and $ENV{'MOD_PERL'} =~ m{mod_perl/(?:1\.9)};
-
+    # bring this in before mason, to make sure we
+    # use private tempfiles
+    use CGI qw(-private_tempfiles);
 }
 
 # fix lib paths, some may be relative
@@ -88,91 +130,44 @@ BEGIN {
     }
 
 }
-use RT;
-
-package RT::Mason;
 
-use vars qw($Nobody $SystemUser $Handler $r);
-
-#This drags in RT's config.pm
-BEGIN {
-    RT::LoadConfig();
-    if (RT->Config->Get('DevelMode')) { require Module::Refresh; }
-    RT->InitPluginPaths();
+require RT;
+RT::LoadConfig();
+if ( RT->Config->Get('DevelMode') ) {
+    require Module::Refresh;
 }
+RT::Init();
 
+# check compatibility of the DB
 {
-    require RT::Handle;
-    my $dsn = RT::Handle->DSN;
-    my $user = RT->Config->Get('DatabaseUser');
-    my $pass = RT->Config->Get('DatabasePassword');
-
-    my $dbh = DBI->connect(
-        $dsn, $user, $pass,
-        { RaiseError => 0, PrintError => 0 },
-    );
+    my $dbh = $RT::Handle->dbh;
     if ( $dbh ) {
-        my ($status, $msg) = RT::Handle->CheckCompatibility( $dbh, 'post' );
+        my ($status, $msg) = $RT::Handle->CheckCompatibility( $dbh, 'post' );
         die $msg unless $status;
     }
 }
 
-{
-    package HTML::Mason::Commands;
-    use vars qw(%session);
-}
+require RT::Interface::Web::Handler;
+$RT::Mason::Handler = RT::Interface::Web::Handler->new(
+    RT->Config->Get('MasonParameters')
+);
 
-use RT::Interface::Web;
-use RT::Interface::Web::Handler;
+# we must disconnect DB before fork
+$RT::Handle->dbh(undef);
+undef $RT::Handle;
 
-if ($ENV{'MOD_PERL'} && !RT->Config->Get('DevelMode')) {
+if ( $ENV{'MOD_PERL'} && !RT->Config->Get('DevelMode')) {
     # Under static_source, we need to purge the component cache
     # each time we restart, so newer components may be reloaded.
     #
-    # We can't do this in FastCGI or we'll blow away the component root _every_ time a new server starts
-    # which happens every few hits.
+    # We can't do this in FastCGI or we'll blow away the component
+    # root _every_ time a new server starts which happens every few
+    # hits.
     
-    use File::Path qw( rmtree );
-    use File::Glob qw( bsd_glob );
-    my @files = bsd_glob("$RT::MasonDataDir/obj/*");
-    rmtree([ @files ], 0, 1) if @files;
-}
-
-sub handler {
-    ($r) = @_;
-
-    local $SIG{__WARN__};
-    local $SIG{__DIE__};
-
-    if ($r->content_type =~ m/^httpd\b.*\bdirectory/i) {
-        use File::Spec::Unix;
-        # Our DirectoryIndex is always index.html, regardless of httpd settings
-        $r->filename( File::Spec::Unix->catfile( $r->filename, 'index.html' ) );
-    }
-#    elsif (defined( $r->content_type )) {
-        #$r->content_type !~ m!(^text/|\bxml\b)!i or return -1;
-#    }
-
-    Module::Refresh->refresh if RT->Config->Get('DevelMode');
-
-    RT::Init();
-
-    $Handler ||= RT::Interface::Web::Handler->new(
-        RT->Config->Get('MasonParameters')
-    );
-
-    my %session;
-    my $status;
-    eval { $status = $Handler->handle_request($r) };
-    if ($@) {
-        $RT::Logger->crit($@);
-    }
-
-    undef(%session);
-
-    RT::Interface::Web::Handler->CleanupRequest();
-
-    return $status;
+    require File::Path;
+    require File::Glob;
+    my @files = File::Glob::bsd_glob("$RT::MasonDataDir/obj/*");
+    File::Path::rmtree([ @files ], 0, 1) if @files;
 }
 
 1;

commit d5decef87e2db7037ae6895716a838cd2670c872
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Nov 20 14:17:04 2009 +0300

    generate LockFile option for apache as well
    
    It's all crazy, defaults can be absolute and not relative to
    the root.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 301785e..71abe63 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1034,26 +1034,24 @@ sub start_apache_server {
         <$fh>
     });
 
-    my $log_fn = File::Spec->catfile(
-        "$tmp{'directory'}", 'apache.log'
-    );
-    my $pid_fn = File::Spec->catfile(
-        "$tmp{'directory'}", "apache.pid"
-    );
     my $tmpl = File::Spec->rel2abs( File::Spec->catfile(
         't', 'data', 'configs',
         'apache'. $info{'version'} .'+'. $variant .'.conf'
     ) );
     my %opt = (
-        listen        => $port,
-        server_root   => $info{'HTTPD_ROOT'} || $ENV{'HTTPD_ROOT'}
+        listen         => $port,
+        server_root    => $info{'HTTPD_ROOT'} || $ENV{'HTTPD_ROOT'}
             || Test::More::BAIL_OUT("Couldn't figure out server root"),
-        pid_file      => $pid_fn,
-        document_root => $RT::MasonComponentRoot,
-        rt_bin_path   => $RT::BinPath,
-        log_file      => $log_fn,
+        document_root  => $RT::MasonComponentRoot,
+        tmp_dir        => "$tmp{'directory'}",
+        rt_bin_path    => $RT::BinPath,
         rt_site_config => $ENV{'RT_SITE_CONFIG'},
     );
+    foreach (qw(log pid lock)) {
+        $opt{$_ .'_file'} = File::Spec->catfile(
+            "$tmp{'directory'}", "apache.$_"
+        );
+    }
     {
         my $method = 'apache_'.$variant.'_server_options';
         $self->$method( \%info, \%opt );
@@ -1070,14 +1068,14 @@ sub start_apache_server {
     $self->fork_exec($info{'executable'}, '-f', $tmp{'config'}{'apache'});
     my $pid = do {
         my $tries = 10;
-        while ( !-e $pid_fn ) {
+        while ( !-e $opt{'pid_file'} ) {
             $tries--;
             last unless $tries;
             sleep 1;
         }
         Test::More::BAIL_OUT("Couldn't start apache server, no pid file")
-            unless -e $pid_fn;
-        open my $pid_fh, '<', $pid_fn
+            unless -e $opt{'pid_file'};
+        open my $pid_fh, '<', $opt{'pid_file'}
             or Test::More::BAIL_OUT("Couldn't open pid file: $!");
         my $pid = <$pid_fh>;
         chomp $pid;

commit f59c0c6946972029cfbaad22cdb8cad90ad527a1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Nov 20 14:20:36 2009 +0300

    don't delete tmp when we bail out

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 71abe63..5615324 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1267,11 +1267,11 @@ END {
     RT::Test->stop_server;
 
     # not success
-    if ( grep !$_, $Test->summary ) {
+    if ( !$Test->summary || grep !$_, $Test->summary ) {
         $tmp{'directory'}->unlink_on_destroy(0);
 
         Test::More::diag(
-            "Some tests failed, tmp directory"
+            "Some tests failed or we bailed out, tmp directory"
             ." '$tmp{directory}' is not cleaned"
         );
     }

commit 69a647bbc54ce4b75fde2703229ff37792f9a870
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Nov 20 14:21:19 2009 +0300

    set LockFile and don't set TypesConfig

diff --git a/t/data/configs/apache2.2+fastcgi.conf.in b/t/data/configs/apache2.2+fastcgi.conf.in
index c0c01d1..75cbadb 100644
--- a/t/data/configs/apache2.2+fastcgi.conf.in
+++ b/t/data/configs/apache2.2+fastcgi.conf.in
@@ -1,11 +1,11 @@
 ServerRoot %%SERVER_ROOT%%
 PidFile %%PID_FILE%%
+LockFile %%LOCK_FILE%%
 ServerAdmin root at localhost
 
 %%LOAD_MODULES%%
 
-TypesConfig /etc/mime.types
-FastCgiIpcDir /tmp
+FastCgiIpcDir %%TMP_DIR%%
 
 <IfModule !mpm_netware_module>
 <IfModule !mpm_winnt_module>
diff --git a/t/data/configs/apache2.2+mod_perl.conf.in b/t/data/configs/apache2.2+mod_perl.conf.in
index ed12c86..3d28c2c 100644
--- a/t/data/configs/apache2.2+mod_perl.conf.in
+++ b/t/data/configs/apache2.2+mod_perl.conf.in
@@ -1,5 +1,6 @@
 ServerRoot %%SERVER_ROOT%%
 PidFile %%PID_FILE%%
+LockFile %%LOCK_FILE%%
 ServerAdmin root at localhost
 
 %%LOAD_MODULES%%

commit d2ea884f8adeaecf50c2914912cfa111d814c337
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Nov 21 03:06:54 2009 +0300

    don't create handles we don't need, we can hit limit

diff --git a/lib/RT/Crypt/GnuPG.pm b/lib/RT/Crypt/GnuPG.pm
index 5581df1..40fd477 100644
--- a/lib/RT/Crypt/GnuPG.pm
+++ b/lib/RT/Crypt/GnuPG.pm
@@ -2411,16 +2411,10 @@ sub Probe {
 
 
 sub _make_gpg_handles {
-    my %handle_map = (
-        stdin  => IO::Handle->new(),
-        stdout => IO::Handle->new(),
-        stderr => IO::Handle->new(),
-        logger => IO::Handle->new(),
-        status => IO::Handle->new(),
-        command => IO::Handle->new(),
-
-
-            @_);
+    my %handle_map = (@_);
+    $handle_map{$_} = IO::Handle->new
+        foreach grep !defined $handle_map{$_}, 
+        qw(stdin stdout stderr logger status command);
 
     my $handles = GnuPG::Handles->new(%handle_map);
     return ($handles, \%handle_map);

commit 9b6cb6aa2ca22a189566b41b6d34cd3c03927969
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Nov 21 03:08:10 2009 +0300

    more debug from gpg probe

diff --git a/lib/RT/Crypt/GnuPG.pm b/lib/RT/Crypt/GnuPG.pm
index 40fd477..b8e2cb2 100644
--- a/lib/RT/Crypt/GnuPG.pm
+++ b/lib/RT/Crypt/GnuPG.pm
@@ -2399,11 +2399,17 @@ sub Probe {
 # it's general error system error or incorrect command, command is correct,
 # but there is no way to get actuall error
     if ( $? && ($? >> 8) != 2 ) {
-        $RT::Logger->debug(
-            "Probe for GPG failed."
+        my $msg = "Probe for GPG failed."
             ." Process exitted with code ". ($? >> 8)
             . ($? & 127 ? (" as recieved signal ". ($? & 127)) : '')
-        );
+            . ".";
+        foreach ( qw(stderr logger status) ) {
+            my $tmp = do { local $/; readline $handle{$_} };
+            next unless $tmp && $tmp =~ /\S/s;
+            close $handle{$_};
+            $msg .= "\n$_:\n$tmp\n";
+        }
+        $RT::Logger->debug( $msg );
         return 0;
     }
     return 1;

commit 1f6c85d7a87757635a2c40ca12ede106edc0df10
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Nov 21 03:12:38 2009 +0300

    fix safe_run_child when code dies between fork and exec

diff --git a/lib/RT/Util.pm b/lib/RT/Util.pm
index dd15721..03d27a3 100644
--- a/lib/RT/Util.pm
+++ b/lib/RT/Util.pm
@@ -54,6 +54,42 @@ use base 'Exporter';
 our @EXPORT = qw/safe_run_child/;
 
 sub safe_run_child (&) {
+    my $our_pid = $$;
+
+    # situation here is wierd, running external app
+    # involves fork+exec. At some point after fork,
+    # but before exec (or during) code can die in a
+    # child. Local is no help here as die throws
+    # error out of scope and locals are reset to old
+    # values. Instead we set values, eval code, check pid
+    # on failure and reset values only in our original
+    # process
+    my $dbh = $RT::Handle->dbh;
+    $dbh->{'InactiveDestroy'} = 1 if $dbh;
+    $RT::Handle->{'DisconnectHandleOnDestroy'} = 0;
+
+    my @res;
+    my $want = wantarray;
+    eval {
+        unless ( defined $want ) {
+            _safe_run_child( @_ );
+        } elsif ( $want ) {
+            @res = _safe_run_child( @_ );
+        } else {
+            @res = ( scalar _safe_run_child( @_ ) );
+        }
+        1;
+    } or do {
+        if ( $our_pid == $$ ) {
+            $dbh->{'InactiveDestroy'} = 0 if $dbh;
+            $RT::Handle->{'DisconnectHandleOnDestroy'} = 1;
+        }
+        die $@;
+    };
+    return $want? (@res) : $res[0];
+}
+
+sub _safe_run_child {
     local @ENV{ 'LANG', 'LC_ALL' } = ( 'C', 'C' );
 
     return shift->() if $ENV{'MOD_PERL'} || $CGI::SpeedyCGI::i_am_speedy;

commit 035984441ce761d9ac652f207823946bfa2b7f58
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Nov 21 03:25:05 2009 +0300

    get rid of some things we don't need anymore

diff --git a/bin/mason_handler.fcgi.in b/bin/mason_handler.fcgi.in
index 48155f2..baf407d 100755
--- a/bin/mason_handler.fcgi.in
+++ b/bin/mason_handler.fcgi.in
@@ -46,23 +46,16 @@
 # those contributions and any derivatives thereof.
 # 
 # END BPS TAGGED BLOCK }}}
-package RT::Mason;
-
 use strict;
-use vars '$Handler';
-use File::Basename;
+use warnings;
+no warnings qw(once);
 
-require (dirname(__FILE__) . '/webmux.pl');
+use File::Basename;
+require (dirname(__FILE__) .'/webmux.pl');
 
 # Enter CGI::Fast mode, which should also work as a vanilla CGI script.
 require CGI::Fast;
 
-RT::Init();
-$Handler ||= RT::Interface::Web::Handler->new(
-    RT->Config->Get('MasonParameters')
-);
-
-
 while ( my $cgi = CGI::Fast->new ) {
     # the whole point of fastcgi requires the env to get reset here..
     # So we must squash it again
@@ -75,12 +68,16 @@ while ( my $cgi = CGI::Fast->new ) {
     Module::Refresh->refresh if RT->Config->Get('DevelMode');
     RT::ConnectToDatabase();
 
-    if ( ( !$Handler->interp->comp_exists( $cgi->path_info ) )
-        && ( $Handler->interp->comp_exists( $cgi->path_info . "/index.html" ) ) ) {
+    my $interp = $RT::Mason::Handler->interp;
+    if (
+        !$interp->comp_exists( $cgi->path_info )
+        && $interp->comp_exists( $cgi->path_info . "/index.html" )
+    ) {
         $cgi->path_info( $cgi->path_info . "/index.html" );
     }
 
-    eval { $Handler->handle_cgi_object($cgi); };
+    local $@;
+    eval { $RT::Mason::Handler->handle_cgi_object($cgi); };
     if ($@) {
         $RT::Logger->crit($@);
     }

commit a79f4ca97b416d4c3560981df5d01c029a5319d8
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Nov 21 17:20:27 2009 +0300

    port scgi handler to new code

diff --git a/bin/mason_handler.scgi.in b/bin/mason_handler.scgi.in
index a853529..cd24bc8 100755
--- a/bin/mason_handler.scgi.in
+++ b/bin/mason_handler.scgi.in
@@ -56,18 +56,13 @@ require (dirname(__FILE__) . '/webmux.pl');
 
 require CGI;
 
-RT::Init();
-$Handler ||= RT::Interface::Web::Handler->new(
-    RT->Config->Get('MasonParameters')
-);
-
-
 my $cgi = CGI->new;
 if ( ( !$Handler->interp->comp_exists( $cgi->path_info ) )
     && ( $Handler->interp->comp_exists( $cgi->path_info . "/index.html" ) ) ) {
     $cgi->path_info( $cgi->path_info . "/index.html" );
 }
 
+RT::ConnectToDatabase();
 $Handler->handle_cgi_object($cgi);
 RT::Interface::Web::Handler->CleanupRequest();
 1;

commit daee1605f241578a7cdc6e3ac7a0068de65fb61f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Nov 23 02:17:38 2009 +0300

    first implementation of FCGI server

diff --git a/bin/fastcgi_server.in b/bin/fastcgi_server.in
new file mode 100644
index 0000000..e57de4e
--- /dev/null
+++ b/bin/fastcgi_server.in
@@ -0,0 +1,98 @@
+#!@PERL@
+# BEGIN BPS TAGGED BLOCK {{{
+# 
+# COPYRIGHT:
+# 
+# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+#                                          <jesse at bestpractical.com>
+# 
+# (Except where explicitly superseded by other copyright notices)
+# 
+# 
+# LICENSE:
+# 
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+# 
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+# 
+# 
+# CONTRIBUTION SUBMISSION POLICY:
+# 
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+# 
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+# 
+# END BPS TAGGED BLOCK }}}
+use strict;
+use warnings;
+no warnings qw(once);
+
+package RT::Interface::Web::FCGI::Server;
+use base qw(FCGI::ProcManager);
+
+package main;
+
+use File::Basename;
+require (dirname(__FILE__) .'/webmux.pl');
+
+require CGI::Fast;
+
+my $proc_manager = RT::Interface::Web::FCGI::Server->new({
+    n_processes => 10,
+});
+$proc_manager->pm_manage();
+
+while ( my $cgi = CGI::Fast->new ) {
+    $proc_manager->pm_pre_dispatch;
+
+    $ENV{'PATH'}   = '/bin:/usr/bin';
+    $ENV{'CDPATH'} = '' if defined $ENV{'CDPATH'};
+    $ENV{'SHELL'}  = '/bin/sh' if defined $ENV{'SHELL'};
+    $ENV{'ENV'}    = '' if defined $ENV{'ENV'};
+    $ENV{'IFS'}    = '' if defined $ENV{'IFS'};
+
+    Module::Refresh->refresh if RT->Config->Get('DevelMode');
+    RT::ConnectToDatabase();
+
+    my $interp = $RT::Mason::Handler->interp;
+    if (
+        !$interp->comp_exists( $cgi->path_info )
+        && $interp->comp_exists( $cgi->path_info . "/index.html" )
+    ) {
+        $cgi->path_info( $cgi->path_info . "/index.html" );
+    }
+
+    local $@;
+    eval { $RT::Mason::Handler->handle_cgi_object($cgi); };
+    if ($@) {
+        $RT::Logger->crit($@);
+    }
+    RT::Interface::Web::Handler->CleanupRequest;
+
+    $proc_manager->pm_post_dispatch;
+}
+
+1;

-----------------------------------------------------------------------


More information about the Rt-commit mailing list