mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge pull request #7096 from appwrite/refactor-db-health
Refactor db health api
This commit is contained in:
commit
2baadb6e95
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),
|
||||||
|
|
@ -536,10 +532,10 @@ App::get('/v1/health/storage/local')
|
||||||
|
|
||||||
foreach (
|
foreach (
|
||||||
[
|
[
|
||||||
'Uploads' => APP_STORAGE_UPLOADS,
|
'Uploads' => APP_STORAGE_UPLOADS,
|
||||||
'Cache' => APP_STORAGE_CACHE,
|
'Cache' => APP_STORAGE_CACHE,
|
||||||
'Config' => APP_STORAGE_CONFIG,
|
'Config' => APP_STORAGE_CONFIG,
|
||||||
'Certs' => APP_STORAGE_CERTIFICATES
|
'Certs' => APP_STORAGE_CERTIFICATES
|
||||||
] as $key => $volume
|
] as $key => $volume
|
||||||
) {
|
) {
|
||||||
$device = new Local($volume);
|
$device = new Local($volume);
|
||||||
|
|
@ -601,7 +597,7 @@ App::get('/v1/health/anti-virus')
|
||||||
});
|
});
|
||||||
|
|
||||||
App::get('/v1/health/stats') // Currently only used internally
|
App::get('/v1/health/stats') // Currently only used internally
|
||||||
->desc('Get system stats')
|
->desc('Get system stats')
|
||||||
->groups(['api', 'health'])
|
->groups(['api', 'health'])
|
||||||
->label('scope', 'root')
|
->label('scope', 'root')
|
||||||
// ->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
// ->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue