12 lines
422 B
PHP
12 lines
422 B
PHP
<?php
|
|
// Check Apache + PHP + database readiness without requiring curl in the image.
|
|
$socket = @fsockopen('127.0.0.1', 80, $errno, $error, 3);
|
|
if (!$socket) {
|
|
exit(1);
|
|
}
|
|
stream_set_timeout($socket, 3);
|
|
fwrite($socket, "GET /healthz HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n");
|
|
$status = fgets($socket);
|
|
fclose($socket);
|
|
exit(is_string($status) && preg_match('/^HTTP\/\d\.\d 200\b/', $status) ? 0 : 1);
|