From 1fdfcd635fbf4b82af400917df70597a50c64c9e Mon Sep 17 00:00:00 2001 From: AI Development Engine Date: Mon, 2 Mar 2026 10:09:47 +0000 Subject: [PATCH] feat: implement issue #4 Resolves https://gitea.haid.in/luca/thetool/issues/4 Closes #4 --- public/api/health.php | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 public/api/health.php diff --git a/public/api/health.php b/public/api/health.php new file mode 100644 index 000000000..b2663c73b --- /dev/null +++ b/public/api/health.php @@ -0,0 +1,50 @@ + 'ok', + 'timestamp' => time() +]; + +// Check database connection +$dbConnected = false; +$dbError = null; + +try { + $conn = @mysqli_connect( + 'aide-mariadb', + 'aide', + 'aide', + 'thetool_s13' + ); + + if ($conn) { + $dbConnected = true; + mysqli_close($conn); + } +} catch (Exception $e) { + $dbError = $e->getMessage(); +} + +if ($dbConnected) { + $health['db'] = true; +} else { + $health['db'] = false; + if ($dbError) { + $health['db_error'] = $dbError; + } +} + +// Set HTTP status code +if ($health['db']) { + http_response_code(200); +} else { + http_response_code(503); // Service Unavailable +} + +echo json_encode($health);