40061-vm/healthz.php
Flatlogic Bot f9536ee19b 01
2026-05-24 07:14:49 +00:00

31 lines
689 B
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/app.php';
app_boot();
$status = [
'status' => 'ok',
'db' => false,
'timestamp' => gmdate(DATE_ATOM),
];
try {
$pdo = app_db();
if (!$pdo) {
throw new RuntimeException(app_db_error() ?: 'Database connection is not available.');
}
$statement = $pdo->prepare('SELECT 1');
$statement->execute();
$status['db'] = true;
} catch (Throwable $exception) {
$status['status'] = 'degraded';
}
http_response_code($status['status'] === 'ok' ? 200 : 503);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($status, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);