-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstatus.php
More file actions
77 lines (68 loc) · 2.58 KB
/
status.php
File metadata and controls
77 lines (68 loc) · 2.58 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
67
68
69
70
71
72
73
74
75
76
77
<?php
//
// Drupal status check
//
// Original by [Lullabot](http://www.lullabot.com/articles/varnish-multiple-web-servers-drupal)
// Adapted for DrupalCONCEPT by Jochen Lillich <jochen@freistil-consulting.de>
//
// 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() {
exit();
}
// Drupal bootstrap.
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
// Build up our list of errors.
$errors = array();
// Check that the main database is active.
$result = db_query('SELECT * FROM {users} WHERE uid = 1');
$account = db_fetch_object($result);
if (!$account->uid == 1) {
$errors[] = 'Master database not responding.';
}
// Check that the slave database is active.
if (function_exists('db_query_slave')) {
$result = db_query_slave('SELECT * FROM {users} WHERE uid = 1');
$account = db_fetch_object($result);
if (!$account->uid == 1) {
$errors[] = 'Slave database not responding.';
}
}
// Check that all memcache instances are running on this server.
if (isset($conf['cache_inc'])) {
foreach ($conf['memcache_servers'] as $address => $bin) {
list($ip, $port) = explode(':', $address);
if (!memcache_connect($ip, $port)) {
$errors[] = 'Memcache bin <em>' . $bin . '</em> at address ' . $address . ' is not available.';
}
}
}
// Check that the files directory is operating properly.
if ($test = tempnam(variable_get('file_directory_path', conf_path() .'/files'), 'status_check_')) {
// Uncomment to check if files are saved in the correct server directory.
//if (!strpos($test, '/mnt/nfs') === 0) {
// $errors[] = 'Files are not being saved in the NFS mount under /mnt/nfs.';
//}
if (!unlink($test)) {
$errors[] = 'Could not delete newly create files in the files directory.';
}
}
else {
$errors[] = 'Could not create temporary file in the files directory.';
}
// Print all errors.
if ($errors) {
$errors[] = 'Errors on this server will cause it to be removed from the load balancer.';
header('HTTP/1.1 500 Internal Server Error');
print implode("<br />\n", $errors);
}
else {
// Split up this message, to prevent the remote chance of monitoring software
// reading the source code if mod_php fails and then matching the string.
print 'CONGRATULATIONS' . ' 200';
}
// Exit immediately, note the shutdown function registered at the top of the file.
exit();