[Rt-commit] rt branch, 4.0/sanity-check-url-config, updated. rt-3.9.7-1150-g8ac8c92

Shawn Moore sartak at bestpractical.com
Fri Mar 4 18:38:11 EST 2011


The branch, 4.0/sanity-check-url-config has been updated
       via  8ac8c928cdc1bb940617b1f9f7dda1b694b0fb4d (commit)
       via  8c6ce9794fb3cc7959e901faef13794c00b6eaf7 (commit)
      from  a1f2fef4ffb0ae40efacc4cdb7c1ba8cee31cdad (commit)

Summary of changes:
 lib/RT/Interface/Web.pm |    6 +++---
 sbin/rt-server.in       |   43 +++++++++++++++++++++++++++----------------
 2 files changed, 30 insertions(+), 19 deletions(-)

- Log -----------------------------------------------------------------
commit 8c6ce9794fb3cc7959e901faef13794c00b6eaf7
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Mar 4 18:21:27 2011 -0500

    Clean up and simplify rt-server's --port configuration

diff --git a/sbin/rt-server.in b/sbin/rt-server.in
index 7cd565c..f5b47a6 100755
--- a/sbin/rt-server.in
+++ b/sbin/rt-server.in
@@ -162,10 +162,6 @@ unless ($0 eq __FILE__) {
 
 # load appropriate server
 
-my $explicit_port = $ARGV[0] && $ARGV[0] !~ m/-/ ? shift @ARGV : undef;
-warn "Deprecated: please run $0 --port $explicit_port instead".$/ if $explicit_port;
-my $port = $explicit_port || RT->Config->Get('WebPort') || '8080';
-
 require Plack::Runner;
 
 my $is_fastcgi = $0 =~ m/fcgi$/;
@@ -173,28 +169,43 @@ my $r = Plack::Runner->new( $0 =~ 'standalone' ? ( server => 'Standalone' ) :
                             $is_fastcgi        ? ( server => 'FCGI' )
                                                : (),
                             env => 'deployment' );
+
+# figure out the port
+my $port;
+
+# handle "rt-server 8888" for back-compat, but complain about it
+if ($ARGV[0] && $ARGV[0] =~ m/^\d+$/) {
+    warn "Deprecated: please run $0 --port $ARGV[0] instead\n";
+    unshift @ARGV, '--port';
+}
+
 my @args = @ARGV;
 
 use List::MoreUtils 'last_index';
-my $last_index = last_index { $_ eq '--port' } @args; 
+my $last_index = last_index { $_ eq '--port' } @args;
+
+my $explicit_port;
 
 if ( $last_index != -1 && $args[$last_index+1] =~ /^\d+$/ ) {
-    $port = $args[$last_index+1];
+    $explicit_port = $args[$last_index+1];
+    $port = $explicit_port;
+
+    # inform the rest of the system what port we manually chose
+    my $old_app = $app;
+    $app = sub {
+        my $env = shift;
+
+        $env->{'rt.port'} = $port;
+
+        $old_app->($env, @_);
+    };
 }
 else {
+    # default to the configured WebPort and inform Plack::Runner
+    $port = RT->Config->Get('WebPort') || '8080';
     push @args, '--port', $port;
 }
 
-# inform the rest of the system what port we're using
-my $old_app = $app;
-$app = sub {
-    my $env = shift;
-
-    $env->{'rt.port'} = $port;
-
-    $old_app->($env, @_);
-};
-
 push @args, '--server', 'Standalone' if RT->InstallMode;
 push @args, '--server', 'Starlet' unless $r->{server} || grep { m/--server/ } @args;
 

commit 8ac8c928cdc1bb940617b1f9f7dda1b694b0fb4d
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Mar 4 18:22:16 2011 -0500

    Call the %ENV key rt.explicit_port instead of rt.port

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 82c153f..0f14341 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1013,9 +1013,9 @@ sub ValidateWebConfig {
     return if $_has_validated_web_config;
     $_has_validated_web_config = 1;
 
-    if ($ENV{'rt.port'}) {
-        if ($ENV{SERVER_PORT} != $ENV{'rt.port'}) {
-            $RT::Logger->warn("The actual SERVER_PORT ($ENV{SERVER_PORT}) does NOT match the requested port ($ENV{'rt.port'}). Perhaps you should Set(\$WebPort, $ENV{SERVER_PORT}) in RT_SiteConfig.pm, otherwise your internal links may be broken.");
+    if ($ENV{'rt.explicit_port'}) {
+        if ($ENV{SERVER_PORT} != $ENV{'rt.explicit_port'}) {
+            $RT::Logger->warn("The actual SERVER_PORT ($ENV{SERVER_PORT}) does NOT match the requested port ($ENV{'rt.explicit_port'}). Perhaps you should Set(\$WebPort, $ENV{SERVER_PORT}) in RT_SiteConfig.pm, otherwise your internal links may be broken.");
         }
     }
     else {
diff --git a/sbin/rt-server.in b/sbin/rt-server.in
index f5b47a6..75cb012 100755
--- a/sbin/rt-server.in
+++ b/sbin/rt-server.in
@@ -195,7 +195,7 @@ if ( $last_index != -1 && $args[$last_index+1] =~ /^\d+$/ ) {
     $app = sub {
         my $env = shift;
 
-        $env->{'rt.port'} = $port;
+        $env->{'rt.explicit_port'} = $port;
 
         $old_app->($env, @_);
     };

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


More information about the Rt-commit mailing list