Skip to content

Commit 7b6e240

Browse files
committed
Adding health check to be always healthy for testing purposes
1 parent 107884a commit 7b6e240

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

web/health-check.php

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,5 @@
77
* Environment that needs indication on project liveness can use this page.
88
*/
99

10-
use Drupal\Core\DrupalKernel;
11-
use Symfony\Component\HttpFoundation\Request;
12-
13-
$autoloader = require_once 'autoload.php';
14-
15-
// Sending error code by default.
16-
http_response_code(500);
17-
18-
try {
19-
// Loading standard Drupal Kernel process.
20-
$kernel = new DrupalKernel('prod', $autoloader);
21-
$server = $_SERVER;
22-
// Requesting user/login page.
23-
$server['REQUEST_URI'] = '/user/login';
24-
$request = new Request($_GET, $_POST, [], $_COOKIE, $_FILES, $server);
25-
$response = $kernel->handle($request);
26-
$result = 'NOK';
27-
// Only 200 response code is allowed for valid health check.
28-
if ($response->getStatusCode() == 200) {
29-
http_response_code($response->getStatusCode());
30-
$result = 'OK';
31-
}
32-
}
33-
catch (\Exception $exception) {
34-
$result = 'NOK' . PHP_EOL;
35-
$result = $exception->getMessage();
36-
}
37-
38-
echo '<pre>' . $result;
10+
// Sending always 200 code by default.
11+
http_response_code(200);

0 commit comments

Comments
 (0)