Compare commits
1 Commits
ai/issue-6
...
ai/issue-4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fdfcd635f |
50
public/api/health.php
Normal file
50
public/api/health.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Health Check Endpoint
|
||||||
|
* Returns application health status and database connectivity
|
||||||
|
*/
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$health = [
|
||||||
|
'status' => '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);
|
||||||
Reference in New Issue
Block a user