forked from kamba4/sunders
feat: web healthcheck returns 503 status code if database is unavailable
This commit is contained in:
parent
5ff2918d07
commit
729af9ced9
2 changed files with 4 additions and 4 deletions
|
|
@ -6,8 +6,9 @@
|
|||
/* Connect to database */
|
||||
$mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB);
|
||||
if($mysqli->connect_errno) {
|
||||
http_response_code(503);
|
||||
header('Content-type: application/json');
|
||||
$result = '{"error":"error while connecting to db : ' . $mysqli->error . '"}';
|
||||
$result = '{"error":"Database unavailable"}';
|
||||
echo $result;
|
||||
exit;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue