mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merged from MOODLE_14_STABLE - Pedantic HTTP correctness; now we return an appropriate 503 HTTP status code when the database is unreachable and assumed overloaded. This is for the benefit of monitoring and load testing scripts.
This commit is contained in:
parent
e4acc4ce48
commit
b350cb9d93
1 changed files with 9 additions and 0 deletions
|
@ -88,6 +88,14 @@ global $THEME;
|
|||
$dbconnected = $db->Connect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname);
|
||||
}
|
||||
if (! $dbconnected) {
|
||||
// In the name of protocol correctness, monitoring and performance
|
||||
// profiling, set the appropriate error headers for machine comsumption
|
||||
if (isset($_SERVER['SERVER_PROTOCOL'])) {
|
||||
// Avoid it with cron.php. Note that we assume it's HTTP/1.x
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
|
||||
}
|
||||
// and then for human consumption...
|
||||
echo '<html><body>';
|
||||
echo '<table align="center"><tr>';
|
||||
echo '<td style="color:#990000; text-align:center; font-size:large; border-width:1px; '.
|
||||
' border-color:#000000; border-style:solid; border-radius: 20px; border-collapse: collapse; '.
|
||||
|
@ -96,6 +104,7 @@ global $THEME;
|
|||
echo '<p>It is possible that the database is overloaded or otherwise not running properly.</p>';
|
||||
echo '<p>The site administrator should also check that the database details have been correctly specified in config.php</p>';
|
||||
echo '</td></tr></table>';
|
||||
echo '</body></html>';
|
||||
die;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue