fix: service deletion
This commit is contained in:
parent
1cef233db2
commit
0686e48e89
@ -13,7 +13,6 @@ class DeleteService
|
||||
try {
|
||||
$server = data_get($service, 'server');
|
||||
if ($server->isFunctional()) {
|
||||
StopService::run($service);
|
||||
$storagesToDelete = collect([]);
|
||||
|
||||
$service->environment_variables()->delete();
|
||||
@ -46,7 +45,6 @@ class DeleteService
|
||||
foreach ($service->databases()->get() as $database) {
|
||||
$database->forceDelete();
|
||||
}
|
||||
$service->forceDelete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,10 @@ class StopService
|
||||
use AsAction;
|
||||
public function handle(Service $service)
|
||||
{
|
||||
$server = $service->destination->server;
|
||||
if (!$server->isFunctional()) {
|
||||
return 'Server is not functional';
|
||||
}
|
||||
ray('Stopping service: ' . $service->name);
|
||||
$applications = $service->applications()->get();
|
||||
foreach ($applications as $application) {
|
||||
|
@ -5,6 +5,7 @@ namespace App\Jobs;
|
||||
use App\Actions\Application\StopApplication;
|
||||
use App\Actions\Database\StopDatabase;
|
||||
use App\Actions\Service\DeleteService;
|
||||
use App\Actions\Service\StopService;
|
||||
use App\Models\Application;
|
||||
use App\Models\Service;
|
||||
use App\Models\StandaloneMariadb;
|
||||
@ -30,33 +31,21 @@ class DeleteResourceJob implements ShouldQueue, ShouldBeEncrypted
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$this->resource->forceDelete();
|
||||
switch ($this->resource->type()) {
|
||||
case 'application':
|
||||
StopApplication::run($this->resource);
|
||||
$this->resource->forceDelete();
|
||||
break;
|
||||
case 'standalone-postgresql':
|
||||
StopDatabase::run($this->resource);
|
||||
$this->resource->forceDelete();
|
||||
break;
|
||||
case 'standalone-redis':
|
||||
StopDatabase::run($this->resource);
|
||||
$this->resource->forceDelete();
|
||||
break;
|
||||
case 'standalone-mongodb':
|
||||
StopDatabase::run($this->resource);
|
||||
$this->resource->forceDelete();
|
||||
break;
|
||||
case 'standalone-mysql':
|
||||
StopDatabase::run($this->resource);
|
||||
$this->resource->forceDelete();
|
||||
break;
|
||||
case 'standalone-mariadb':
|
||||
StopDatabase::run($this->resource);
|
||||
$this->resource->forceDelete();
|
||||
break;
|
||||
case 'service':
|
||||
DeleteService::dispatch($this->resource);
|
||||
StopService::run($this->resource);
|
||||
DeleteService::run($this->resource);
|
||||
break;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user