[Rt-commit] rt branch, new-webmux, updated. rt-3.8.5-288-g215446a

Ruslan Zakirov ruz at bestpractical.com
Thu Oct 8 18:20:17 EDT 2009


The branch, new-webmux has been updated
       via  215446ad5be978d2c567c8e411e7e92240d4c43c (commit)
       via  60f77af731bedb408c0428d793dcd9893d514693 (commit)
       via  ea1a8896836537f41b528369aa31ce114088e2cb (commit)
       via  efe59bb822b2410f2b03e3310dbcbca905cb8c2c (commit)
      from  b9dcb5da910e7c7c26d053e9d0e36eac6ce74847 (commit)

Summary of changes:
 bin/webmux.pl.in |  151 ++++++++++++++++++++++++++----------------------------
 lib/RT.pm.in     |    3 +
 lib/RT/Test.pm   |    4 +-
 3 files changed, 78 insertions(+), 80 deletions(-)

- Log -----------------------------------------------------------------
commit efe59bb822b2410f2b03e3310dbcbca905cb8c2c
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 8112045..db76eb1 100755
--- a/lib/RT.pm.in
+++ b/lib/RT.pm.in
@@ -348,7 +348,10 @@ sub InitLogging {
                          ));
         }
     }
+    InitSignalHandlers();
+}
 
+sub InitSignalHandlers {
 
 # Signal handlers
 ## This is the default handling of warnings and die'ings in the code

commit ea1a8896836537f41b528369aa31ce114088e2cb
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 19d3b62..24beb0b 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -961,7 +961,7 @@ sub start_apache_server {
 
     $self->fork_exec($info{'executable'}, '-f', $conf_fn);
     my $pid = do {
-        my $tries = 60;
+        my $tries = 10;
         while ( !-e $pid_fn ) {
             $tries--;
             last unless $tries;

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

    reverse logic

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 24beb0b..d09bfc2 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1136,7 +1136,7 @@ sub process_in_file {
     }
 
     my ($out_fh, $out_conf);
-    if ( $args{'out'} ) {
+    unless ( $args{'out'} ) {
         ($out_fh, $out_conf) = tempfile();
     } else {
         $out_conf = $args{'out'};

commit 215446ad5be978d2c567c8e411e7e92240d4c43c
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;

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


More information about the Rt-commit mailing list