db health api throws an error when ping fails
This commit is contained in:
parent
bae9da5695
commit
dd9d8010c1
1 changed files with 11 additions and 15 deletions
|
@ -87,22 +87,18 @@ App::get('/v1/health/db')
|
||||||
'ping' => \round((\microtime(true) - $checkStart) / 1000)
|
'ping' => \round((\microtime(true) - $checkStart) / 1000)
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$output[] = new Document([
|
$failure[] = $database;
|
||||||
'name' => $key . " ($database)",
|
|
||||||
'status' => 'fail',
|
|
||||||
'ping' => \round((\microtime(true) - $checkStart) / 1000)
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$output[] = new Document([
|
$failure[] = $database;
|
||||||
'name' => $key . " ($database)",
|
|
||||||
'status' => 'fail',
|
|
||||||
'ping' => \round((\microtime(true) - $checkStart) / 1000)
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($failure)) {
|
||||||
|
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'DB failure on: ' . implode(", ", $failure));
|
||||||
|
}
|
||||||
|
|
||||||
$response->dynamic(new Document([
|
$response->dynamic(new Document([
|
||||||
'statuses' => $output,
|
'statuses' => $output,
|
||||||
'total' => count($output),
|
'total' => count($output),
|
||||||
|
|
Loading…
Reference in a new issue