fixed errors found during installing on "Unraid" (#217)

Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
This commit is contained in:
Alexander Piskun
2024-01-26 20:30:37 +03:00
committed by GitHub
parent 500453b802
commit 8a6c373d9a
6 changed files with 41 additions and 13 deletions

View File

@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
## [2.0.2 - 2024-01-28]
### Fixed
- More correct handling of the ExApps installation process when Nextcloud has a non-default directory location(e.g. `Unraid`). #217
- Correct handling of the action of stopping a Docker container when the action is already in progress. #217
- Correct handling of the ExApp deletion action, when during deletion you refresh the page and click delete again. #217
## [2.0.1 - 2024-01-25]
### Fixed

View File

@ -42,7 +42,7 @@ to join us in shaping a more versatile, stable, and secure app landscape.
*Your insights, suggestions, and contributions are invaluable to us.*
]]></description>
<version>2.0.1</version>
<version>2.0.2</version>
<licence>agpl</licence>
<author mail="andrey18106x@gmail.com" homepage="https://github.com/andrey18106">Andrey Borysenko</author>
<author mail="bigcat88@icloud.com" homepage="https://github.com/bigcat88">Alexander Piskun</author>

View File

@ -761,6 +761,9 @@ class ExAppsPageController extends Controller {
*/
public function getAppStatus(string $appId): JSONResponse {
$exApp = $this->exAppService->getExApp($appId);
if (is_null($exApp)) {
return new JSONResponse(['error' => $this->l10n->t('ExApp not found, failed to get status')], Http::STATUS_NOT_FOUND);
}
return new JSONResponse($exApp->getStatus());
}

View File

@ -191,6 +191,9 @@ class DockerActions implements IDeployActions {
$response = $this->guzzleClient->delete($url);
return ['success' => $response->getStatusCode() === 204];
} catch (GuzzleException $e) {
if ($e->getCode() === 409) { // "removal of container ... is already in progress"
return ['success' => true];
}
$this->logger->error('Failed to stop container', ['exception' => $e]);
error_log($e->getMessage());
return ['error' => 'Failed to stop container'];

View File

@ -411,9 +411,14 @@ class AppAPIService {
}, $args);
$args[] = '--no-ansi --no-warnings';
$args = implode(' ', $args);
$occDirectory = null;
if (!file_exists("console.php")) {
$occDirectory = dirname(__FILE__, 5);
}
$this->logger->info(sprintf('Calling occ(directory=%s): %s', $occDirectory ?? 'null', $args));
$process = proc_open('php console.php ' . $args, $descriptors, $pipes, $occDirectory);
if (!is_resource($process)) {
$this->logger->error(sprintf('ExApp %s dispatch_init failed(occDirectory=%s).', $appId, $occDirectory ?? 'null'));
return false;
}
fclose($pipes[0]);
@ -439,25 +444,34 @@ class AppAPIService {
if (!empty($auth)) {
$options['auth'] = $auth;
}
$this->logger->info(sprintf('Performing heartbeat on: %s', $exAppUrl . '/heartbeat'));
$failedHeartbeatCount = 0;
while ($heartbeatAttempts < $maxHeartbeatAttempts) {
$heartbeatAttempts++;
$errorMsg = '';
$statusCode = 0;
try {
$heartbeatResult = $this->client->get($exAppUrl . '/heartbeat', $options);
} catch (\Exception) {
sleep($delay);
continue;
}
$statusCode = $heartbeatResult->getStatusCode();
if ($statusCode === 200) {
$result = json_decode($heartbeatResult->getBody(), true);
if (isset($result['status']) && $result['status'] === 'ok') {
$this->logger->info(sprintf('Successful heartbeat on: %s', $exAppUrl . '/heartbeat'));
return true;
}
}
} catch (\Exception $e) {
$errorMsg = $e->getMessage();
}
$failedHeartbeatCount++; // Log every 10th failed heartbeat
if ($failedHeartbeatCount % 10 == 0) {
$this->logger->warning(
sprintf('Failed heartbeat on %s for %d times. Most recent status=%d, error: %s', $exAppUrl, $failedHeartbeatCount, $statusCode, $errorMsg)
);
}
sleep($delay);
}
return false;
}

View File

@ -126,7 +126,7 @@ class ExAppService {
$this->cache->remove('/exApp_' . $appId);
return true;
}
$this->logger->error(sprintf('Error while unregistering %s ExApp from the database.', $appId));
$this->logger->warning(sprintf('Error while unregistering %s ExApp from the database.', $appId));
} catch (Exception $e) {
$this->logger->error(sprintf('Error while unregistering ExApp: %s', $e->getMessage()), ['exception' => $e]);
}