diff --git a/app/Actions/Application/StopApplication.php b/app/Actions/Application/StopApplication.php index 3ed435049..61005845b 100644 --- a/app/Actions/Application/StopApplication.php +++ b/app/Actions/Application/StopApplication.php @@ -2,8 +2,8 @@ namespace App\Actions\Application; -use App\Models\Application; use App\Actions\Server\CleanupDocker; +use App\Models\Application; use Lorisleiva\Actions\Concerns\AsAction; class StopApplication @@ -14,13 +14,14 @@ class StopApplication { try { $server = $application->destination->server; - if (!$server->isFunctional()) { + if (! $server->isFunctional()) { return 'Server is not functional'; } - ray('Stopping application: ' . $application->name); + ray('Stopping application: '.$application->name); if ($server->isSwarm()) { instant_remote_process(["docker stack rm {$application->uuid}"], $server); + return; } @@ -32,10 +33,11 @@ class StopApplication } if ($dockerCleanup) { - CleanupDocker::run($server, true); + CleanupDocker::dispatch($server, true); } } catch (\Exception $e) { ray($e->getMessage()); + return $e->getMessage(); } } diff --git a/app/Actions/Database/StopDatabase.php b/app/Actions/Database/StopDatabase.php index 0f074bea9..e4cea7cee 100644 --- a/app/Actions/Database/StopDatabase.php +++ b/app/Actions/Database/StopDatabase.php @@ -28,7 +28,7 @@ class StopDatabase $this->stopContainer($database, $database->uuid, 300); if (! $isDeleteOperation) { if ($dockerCleanup) { - CleanupDocker::run($server, true); + CleanupDocker::dispatch($server, true); } } diff --git a/app/Actions/Service/DeleteService.php b/app/Actions/Service/DeleteService.php index 93c79383e..f28e5490e 100644 --- a/app/Actions/Service/DeleteService.php +++ b/app/Actions/Service/DeleteService.php @@ -2,8 +2,8 @@ namespace App\Actions\Service; -use App\Models\Service; use App\Actions\Server\CleanupDocker; +use App\Models\Service; use Lorisleiva\Actions\Concerns\AsAction; class DeleteService @@ -36,7 +36,7 @@ class DeleteService } // Execute volume deletion first, this must be done first otherwise volumes will not be deleted. - if (!empty($commands)) { + if (! empty($commands)) { foreach ($commands as $command) { $result = instant_remote_process([$command], $server, false); if ($result !== 0) { @@ -70,7 +70,7 @@ class DeleteService $service->forceDelete(); if ($dockerCleanup) { - CleanupDocker::run($server, true); + CleanupDocker::dispatch($server, true); } } } diff --git a/app/Actions/Service/StopService.php b/app/Actions/Service/StopService.php index d69898a58..5c7bbc2aa 100644 --- a/app/Actions/Service/StopService.php +++ b/app/Actions/Service/StopService.php @@ -2,8 +2,8 @@ namespace App\Actions\Service; -use App\Models\Service; use App\Actions\Server\CleanupDocker; +use App\Models\Service; use Lorisleiva\Actions\Concerns\AsAction; class StopService @@ -14,21 +14,22 @@ class StopService { try { $server = $service->destination->server; - if (!$server->isFunctional()) { + if (! $server->isFunctional()) { return 'Server is not functional'; } $containersToStop = $service->getContainersToStop(); $service->stopContainers($containersToStop, $server); - if (!$isDeleteOperation) { + if (! $isDeleteOperation) { $service->delete_connected_networks($service->uuid); if ($dockerCleanup) { - CleanupDocker::run($server, true); + CleanupDocker::dispatch($server, true); } } } catch (\Exception $e) { ray($e->getMessage()); + return $e->getMessage(); } } diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php index 37300593e..ac34d064e 100644 --- a/app/Jobs/DeleteResourceJob.php +++ b/app/Jobs/DeleteResourceJob.php @@ -80,7 +80,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue || $this->resource instanceof StandaloneClickhouse; $server = data_get($this->resource, 'server') ?? data_get($this->resource, 'destination.server'); if (($this->dockerCleanup || $isDatabase) && $server) { - CleanupDocker::run($server, true); + CleanupDocker::dispatch($server, true); } if ($this->deleteConnectedNetworks && ! $isDatabase) { @@ -92,7 +92,7 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue } finally { $this->resource->forceDelete(); if ($this->dockerCleanup) { - CleanupDocker::run($server, true); + CleanupDocker::dispatch($server, true); } Artisan::queue('cleanup:stucked-resources'); }