Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Pedantic HTTP correctness; now we return an appropriate 503 HTTP stat…

…us code when the database is unreachable and assumed overloaded. This is for the benefit of monitoring and load testing scripts.
  • Loading branch information...
commit 12c181bc5022f053467e2a1fb7453494f10a3deb 1 parent 4099382
authored March 20, 2005

Showing 1 changed file with 9 additions and 0 deletions. Show diff stats Hide diff stats

  1. 9  lib/setup.php
9  lib/setup.php
@@ -33,6 +33,14 @@
33 33
         $dbconnected = $db->Connect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname);
34 34
     }
35 35
     if (! $dbconnected) {
  36
+        // In the name of protocol correctness, monitoring and performance
  37
+        // profiling, set the appropriate error headers for machine comsumption
  38
+        if (isset($_SERVER['SERVER_PROTOCOL'])) { 
  39
+            // Avoid it with cron.php. Note that we assume it's HTTP/1.x
  40
+            header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');        
  41
+        }
  42
+        // and then for human consumption...
  43
+        echo '<html><body>';
36 44
         echo '<table align="center"><tr>';
37 45
         echo '<td style="color:#990000; text-align:center; font-size:large; border-width:1px; '.
38 46
              '    border-color:#000000; border-style:solid; border-radius: 20px; border-collapse: collapse; '.
@@ -41,6 +49,7 @@
41 49
         echo '<p>It is possible that the database is overloaded or otherwise not running properly.</p>';
42 50
         echo '<p>The site administrator should also check that the database details have been correctly specified in config.php</p>';
43 51
         echo '</td></tr></table>';
  52
+        echo '</body></html>';
44 53
         die;
45 54
     }
46 55
 

0 notes on commit 12c181b

Please sign in to comment.
Something went wrong with that request. Please try again.