Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
tao_actions_Health | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
index | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | use oat\tao\model\service\ApplicationService; |
4 | use oat\tao\model\http\HttpJsonResponseTrait; |
5 | |
6 | class tao_actions_Health extends tao_actions_CommonModule |
7 | { |
8 | use HttpJsonResponseTrait; |
9 | |
10 | /** |
11 | * Simple endpoint for health checking the TAO instance. |
12 | * |
13 | * No need authentication. |
14 | * The client only needs a 200 response. |
15 | */ |
16 | public function index() |
17 | { |
18 | try { |
19 | /** @var ApplicationService $applicationService */ |
20 | $applicationService = $this->getServiceLocator()->get(ApplicationService::SERVICE_ID); |
21 | if ($applicationService->isInstallationFinished()) { |
22 | $this->setSuccessJsonResponse([ |
23 | 'success' => true |
24 | ]); |
25 | } else { |
26 | throw new common_exception_Error('Installation is not finished'); |
27 | } |
28 | } catch (Throwable $exception) { |
29 | $this->logError(sprintf('Error during health check: %s, ', $exception->getMessage())); |
30 | $this->setErrorJsonResponse($exception->getMessage(), $exception->getCode()); |
31 | } |
32 | } |
33 | } |