'885d37', 'runId' => 'coolify-bad-gateway', 'hypothesisId' => $hypothesisId, 'location' => 'health.php', 'message' => $message, 'data' => $data, 'timestamp' => (int) round(microtime(true) * 1000), ]; $line = json_encode($payload, JSON_UNESCAPED_SLASHES) . PHP_EOL; @file_put_contents(__DIR__ . '/debug-885d37.log', $line, FILE_APPEND); @error_log('agent_debug ' . $line); } // #endregion try { agent_debug_health_request_log('H5,H7', 'health request reached PHP', [ 'sapi' => PHP_SAPI, 'request_uri' => $_SERVER['REQUEST_URI'] ?? '', 'http_host' => $_SERVER['HTTP_HOST'] ?? '', 'server_port' => $_SERVER['SERVER_PORT'] ?? '', 'database_url_getenv_present' => getenv('DATABASE_URL') !== false && getenv('DATABASE_URL') !== '', 'database_url_server_present' => isset($_SERVER['DATABASE_URL']) && $_SERVER['DATABASE_URL'] !== '', 'dot_env_file_exists' => file_exists(__DIR__ . '/.env'), ]); if (!extension_loaded('pdo_pgsql')) { throw new RuntimeException('pdo_pgsql extension missing'); } require_once __DIR__ . '/helpers.php'; require_database(); $response = ['status' => 'ok']; agent_debug_health_request_log('H5,H7', 'health request returning ok', [ 'exit_code' => 0, 'response' => $response, ]); echo json_encode($response, JSON_UNESCAPED_UNICODE); } catch (Throwable $e) { http_response_code(503); $response = [ 'status' => 'error', 'message' => $e->getMessage(), ]; agent_debug_health_request_log('H5,H7', 'health request returning error', [ 'exit_code' => 1, 'response' => $response, 'error_class' => get_class($e), ]); echo json_encode($response, JSON_UNESCAPED_UNICODE); exit(1); }