Add detailed logging for health requests in health.php and enhance entrypoint.sh with Apache configuration logging
This commit is contained in:
@@ -98,5 +98,16 @@ else
|
||||
fi
|
||||
|
||||
echo "[flixcooks] Starting Apache..."
|
||||
port_data=$(php -r 'echo json_encode([
|
||||
"env_port" => getenv("PORT") ?: "",
|
||||
"env_host" => getenv("HOST") ?: "",
|
||||
"apache_document_root" => getenv("APACHE_DOCUMENT_ROOT") ?: "",
|
||||
"expected_container_port" => 80,
|
||||
"coolify_hint" => "Application port must be 80",
|
||||
]);')
|
||||
fc_debug_log "H3,H6" "proxy port context before apache start" "$port_data"
|
||||
apache_config_output=$(apache2ctl -S 2>&1 || true)
|
||||
apache_config_data=$(php -r 'echo json_encode(["apache2ctl_S" => $argv[1]]);' -- "$apache_config_output")
|
||||
fc_debug_log "H3,H6" "apache virtualhost config before start" "$apache_config_data"
|
||||
fc_debug_log "H3" "executing web server command" "$(php -r 'echo json_encode(["command" => array_slice($argv, 1)]);' -- "$@")"
|
||||
exec "$@"
|
||||
|
||||
+35
@@ -6,13 +6,43 @@ header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
require __DIR__ . '/config.php';
|
||||
|
||||
// #region agent log
|
||||
function agent_debug_health_request_log(string $hypothesisId, string $message, array $data = []): void {
|
||||
$payload = [
|
||||
'sessionId' => '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);
|
||||
@@ -20,6 +50,11 @@ try {
|
||||
'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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user