refs #952. First revision status endpoint ogAgent
testing/ogcore-api/pipeline/head Something is wrong with the build of this commit
Details
testing/ogcore-api/pipeline/head Something is wrong with the build of this commit
Details
parent
756bea4844
commit
0c94a1921e
|
@ -45,27 +45,23 @@ class StatusAction extends AbstractController
|
|||
}
|
||||
|
||||
try {
|
||||
$response = $this->httpClient->request('POST', 'https://'.$client->getIp().':8000/ogAdmClient/status');
|
||||
$response = $this->httpClient->request('POST', 'https://' . $client->getIp() . ':8000/ogAdmClient/status');
|
||||
|
||||
if ($response->getStatusCode() !== Response::HTTP_OK) {
|
||||
$client->setStatus('off');
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
} else if ($response->getStatusCode() === Response::HTTP_OK) {
|
||||
$client->setStatus('active');
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
$statusCode = $response->getStatusCode();
|
||||
$client->setStatus($statusCode === Response::HTTP_OK ? 'active' : 'off');
|
||||
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
|
||||
$client->setStatus('off');
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return new JsonResponse( data: 'An error occurred', status: Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
return new JsonResponse(
|
||||
data: ['error' => 'An error occurred while communicating with the client'],
|
||||
status: Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return new JsonResponse(status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue