chore: Refactor DockerCleanupJob to remove unused middleware and uniqueId method
This commit is contained in:
parent
960f970822
commit
04e504bb8b
5 changed files with 17 additions and 14 deletions
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace App\Actions\Application;
|
namespace App\Actions\Application;
|
||||||
|
|
||||||
use App\Models\Application;
|
|
||||||
use App\Actions\Server\CleanupDocker;
|
use App\Actions\Server\CleanupDocker;
|
||||||
|
use App\Models\Application;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class StopApplication
|
class StopApplication
|
||||||
|
|
@ -14,13 +14,14 @@ public function handle(Application $application, bool $previewDeployments = fals
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$server = $application->destination->server;
|
$server = $application->destination->server;
|
||||||
if (!$server->isFunctional()) {
|
if (! $server->isFunctional()) {
|
||||||
return 'Server is not functional';
|
return 'Server is not functional';
|
||||||
}
|
}
|
||||||
ray('Stopping application: ' . $application->name);
|
ray('Stopping application: '.$application->name);
|
||||||
|
|
||||||
if ($server->isSwarm()) {
|
if ($server->isSwarm()) {
|
||||||
instant_remote_process(["docker stack rm {$application->uuid}"], $server);
|
instant_remote_process(["docker stack rm {$application->uuid}"], $server);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,10 +33,11 @@ public function handle(Application $application, bool $previewDeployments = fals
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dockerCleanup) {
|
if ($dockerCleanup) {
|
||||||
CleanupDocker::run($server, true);
|
CleanupDocker::dispatch($server, true);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
ray($e->getMessage());
|
ray($e->getMessage());
|
||||||
|
|
||||||
return $e->getMessage();
|
return $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|St
|
||||||
$this->stopContainer($database, $database->uuid, 300);
|
$this->stopContainer($database, $database->uuid, 300);
|
||||||
if (! $isDeleteOperation) {
|
if (! $isDeleteOperation) {
|
||||||
if ($dockerCleanup) {
|
if ($dockerCleanup) {
|
||||||
CleanupDocker::run($server, true);
|
CleanupDocker::dispatch($server, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace App\Actions\Service;
|
namespace App\Actions\Service;
|
||||||
|
|
||||||
use App\Models\Service;
|
|
||||||
use App\Actions\Server\CleanupDocker;
|
use App\Actions\Server\CleanupDocker;
|
||||||
|
use App\Models\Service;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class DeleteService
|
class DeleteService
|
||||||
|
|
@ -36,7 +36,7 @@ public function handle(Service $service, bool $deleteConfigurations, bool $delet
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute volume deletion first, this must be done first otherwise volumes will not be deleted.
|
// 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) {
|
foreach ($commands as $command) {
|
||||||
$result = instant_remote_process([$command], $server, false);
|
$result = instant_remote_process([$command], $server, false);
|
||||||
if ($result !== 0) {
|
if ($result !== 0) {
|
||||||
|
|
@ -70,7 +70,7 @@ public function handle(Service $service, bool $deleteConfigurations, bool $delet
|
||||||
$service->forceDelete();
|
$service->forceDelete();
|
||||||
|
|
||||||
if ($dockerCleanup) {
|
if ($dockerCleanup) {
|
||||||
CleanupDocker::run($server, true);
|
CleanupDocker::dispatch($server, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace App\Actions\Service;
|
namespace App\Actions\Service;
|
||||||
|
|
||||||
use App\Models\Service;
|
|
||||||
use App\Actions\Server\CleanupDocker;
|
use App\Actions\Server\CleanupDocker;
|
||||||
|
use App\Models\Service;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
class StopService
|
class StopService
|
||||||
|
|
@ -14,21 +14,22 @@ public function handle(Service $service, bool $isDeleteOperation = false, bool $
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$server = $service->destination->server;
|
$server = $service->destination->server;
|
||||||
if (!$server->isFunctional()) {
|
if (! $server->isFunctional()) {
|
||||||
return 'Server is not functional';
|
return 'Server is not functional';
|
||||||
}
|
}
|
||||||
|
|
||||||
$containersToStop = $service->getContainersToStop();
|
$containersToStop = $service->getContainersToStop();
|
||||||
$service->stopContainers($containersToStop, $server);
|
$service->stopContainers($containersToStop, $server);
|
||||||
|
|
||||||
if (!$isDeleteOperation) {
|
if (! $isDeleteOperation) {
|
||||||
$service->delete_connected_networks($service->uuid);
|
$service->delete_connected_networks($service->uuid);
|
||||||
if ($dockerCleanup) {
|
if ($dockerCleanup) {
|
||||||
CleanupDocker::run($server, true);
|
CleanupDocker::dispatch($server, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
ray($e->getMessage());
|
ray($e->getMessage());
|
||||||
|
|
||||||
return $e->getMessage();
|
return $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ public function handle()
|
||||||
|| $this->resource instanceof StandaloneClickhouse;
|
|| $this->resource instanceof StandaloneClickhouse;
|
||||||
$server = data_get($this->resource, 'server') ?? data_get($this->resource, 'destination.server');
|
$server = data_get($this->resource, 'server') ?? data_get($this->resource, 'destination.server');
|
||||||
if (($this->dockerCleanup || $isDatabase) && $server) {
|
if (($this->dockerCleanup || $isDatabase) && $server) {
|
||||||
CleanupDocker::run($server, true);
|
CleanupDocker::dispatch($server, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->deleteConnectedNetworks && ! $isDatabase) {
|
if ($this->deleteConnectedNetworks && ! $isDatabase) {
|
||||||
|
|
@ -92,7 +92,7 @@ public function handle()
|
||||||
} finally {
|
} finally {
|
||||||
$this->resource->forceDelete();
|
$this->resource->forceDelete();
|
||||||
if ($this->dockerCleanup) {
|
if ($this->dockerCleanup) {
|
||||||
CleanupDocker::run($server, true);
|
CleanupDocker::dispatch($server, true);
|
||||||
}
|
}
|
||||||
Artisan::queue('cleanup:stucked-resources');
|
Artisan::queue('cleanup:stucked-resources');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue