[Rt-commit] rt branch, 4.2/database-error-503, created. rt-4.2.3-58-g631fef3

Alex Vandiver alexmv at bestpractical.com
Mon Mar 24 17:11:49 EDT 2014


The branch, 4.2/database-error-503 has been created
        at  631fef37129d3c053c83170c92dce7b19f7d9f59 (commit)

- Log -----------------------------------------------------------------
commit 631fef37129d3c053c83170c92dce7b19f7d9f59
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Mar 24 17:10:56 2014 -0400

    Return 503 on database connection error
    
    Fixes issues #23332.

diff --git a/lib/RT/Interface/Web/Handler.pm b/lib/RT/Interface/Web/Handler.pm
index 078091f..74fd4af 100644
--- a/lib/RT/Interface/Web/Handler.pm
+++ b/lib/RT/Interface/Web/Handler.pm
@@ -275,7 +275,14 @@ sub PSGIApp {
             return $self->_psgi_response_cb( $res->finalize ) if $res;
         }
 
-        RT::ConnectToDatabase() unless RT->InstallMode;
+        unless (RT->InstallMode) {
+            unless (eval { RT::ConnectToDatabase() }) {
+                my $res = Plack::Response->new(503);
+                $res->content_type("text/plain");
+                $res->body("Database inaccessable; contact the RT administrator (".RT->Config->Get("OwnerEmail").")");
+                return $self->_psgi_response_cb( $res->finalize, sub { $self->CleanupRequest } );
+            }
+        }
 
         my $req = Plack::Request->new($env);
 

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


More information about the rt-commit mailing list