-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.php
More file actions
66 lines (57 loc) · 1.77 KB
/
status.php
File metadata and controls
66 lines (57 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
$t = array( 'start'=>microtime(true), 'bootstrap'=>null, 'fin'=>null );
header('X-Debug-Stat: php', false);
$t = array( 'start'=>microtime(true), 'bootstrap'=>null, 'fin'=>null );
// Register our shutdown function so that no other shutdown functions run before this one.
// This shutdown function calls exit(), immediately short-circuiting any other shutdown functions,
// such as those registered by the devel.module for statistics.
register_shutdown_function('status_shutdown');
function status_shutdown() {
global $t;
$t['fin'] = microtime(true);
if ( !empty($_GET['timers']) )
{
echo " start({$t['start']}) bootstrap({$t['bootstrap']}) fin({$t['fin']})";
}
exit();
}
if ( !empty($_GET['phponly']) )
{
finish();
}
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
try {
define('DRUPAL_DIR', __DIR__ );
$autoloader = require_once 'autoload.php';
$request = Request::createFromGlobals();
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel->boot();
// $em = $kernel->getContainer()->get('entity.manager');
$connection = \Drupal::database();
$query = $connection->query("SELECT 1 FROM {config}");
$result = $query->fetchAll();
}
catch (Exception $e) {
// Build up our list of errors.
$errors = array();
$errors[]= $e->getMessage();
}
if (!isset($errors) ) { $errors = array(); }
$t['bootstrap'] = microtime(true);
header('X-Debug-Stat: drupal', false);
finish();
function finish()
{
global $errors;
// Print all errors.
if ($errors) {
$errors[] = 'Errors on this server will cause it to be removed from the load balancer.';
header('HTTP/1.1 503 Internal Server Error');
print implode("<br />\n", $errors);
}
else {
print 'Status Ok';
}
exit();
}