* Utility file to check Drupal's health. * When called without parameters checks only database connection. * May be called with 'target' parameter to check only memcached or solr connection. */ // To read configurations include_once '../sites/default/settings.php'; if (!empty($_GET['target'])) { switch ($_GET['target']) { // Check mysql server connection case 'pgsql': list($result, $message) = check_pgsql(); break; // Check memcached server connection // Check memcached server connection case 'memcached': list($result, $message) = check_memcached(); break; // Check solr server connection // Check solr server connection case 'solr': list($result, $message) = check_solr(); break; // None of them // None of them default: list($result, $message) = array(FALSE, "Script: wrong target parameter"); } } else { list($result, $message) = check_pgsql(); } // Build the response
$result = check_memcached(); break; // Check solr server connection // Check solr server connection case 'solr': $result = check_solr(); break; // None of them // None of them default: $result = FALSE; } } else { $result = check_mysql(); if ($result) { $result = check_memcached(); } } // Return error code 500 in case of failure if (!$result) { header('HTTP/1.1 500 Internal Server Error'); } // End of the script exit; /** * Check mysql connection (master & slaves). * * @return FALSE in case of failure and TRUE otherwise. */ function check_mysql() {
$app->get("/status/db/{id}", function ($id) { # Start building the response. $response = new Response(); # Fill the response with the return value of the function that checks # the status of the component. $response->setStatusCode(200, "OK"); $response->setJsonContent(array("ready" => check_db($id))); return $response; }); $app->get("/status/memcached/{id}", function ($id) { # Start building the response. $response = new Response(); # Fill the response with the return value of the function that checks # the status of the component. $response->setStatusCode(200, "OK"); $response->setJsonContent(array("ready" => check_memcached($id))); return $response; }); $app->get("/status/zebra/{id}", function ($id) { # Start building the response. $response = new Response(); # Fill the response with the return value of the function that checks # the status of the component. $response->setStatusCode(200, "OK"); $response->setJsonContent(array("ready" => check_zebra($id))); return $response; }); $app->get("/status/koha/{id}", function ($id) { # Start building the response. $response = new Response(); # Fill the response with the return value of the function that checks