['method' => 'GET', 'timeout' => 10, 'ignore_errors' => true, 'follow_location' => 0, 'header' => "Accept: application/json\r\n"], 'ssl' => ['verify_peer' => true, 'verify_peer_name' => true], ]); $body = @file_get_contents($base.$path, false, $context, 0, 65536); $headers = $http_response_header ?? []; $code = isset($headers[0]) && preg_match('/\s(\d{3})\s/', $headers[0], $match) ? (int) $match[1] : 0; if ($body === false || $code === 0) { fwrite(STDERR, $path." transport failed; check host, TLS certificate and network.\n"); $allReady = false; continue; } $data = json_decode($body, true); // Print selected diagnostic fields only; do not dump arbitrary remote payloads. $report = ['path' => $path, 'http_status' => $code]; foreach (['status', 'check', 'version', 'business_ready', 'database', 'channels'] as $field) { if (is_array($data) && array_key_exists($field, $data) && is_scalar($data[$field])) { $report[$field] = $data[$field]; } } echo json_encode($report, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR).PHP_EOL; if ($code !== 200 || !is_array($data) || ($path === '/healthz' && ($data['status'] ?? '') !== 'alive') || ($path === '/readyz' && ($data['business_ready'] ?? false) !== true)) { $allReady = false; } } echo "Liveness is not business readiness. This script never creates accounts, orders or payments.\n"; exit($allReady ? 0 : 2);