diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php index 22d5718ab..f2a611863 100644 --- a/app/Jobs/DeleteResourceJob.php +++ b/app/Jobs/DeleteResourceJob.php @@ -28,7 +28,7 @@ class DeleteResourceJob implements ShouldQueue, ShouldBeEncrypted { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public function __construct(public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource) + public function __construct(public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource, public bool $deleteConfigurations = false) { } @@ -55,6 +55,9 @@ public function handle() DeleteService::run($this->resource); break; } + if ($this->deleteConfigurations) { + $this->resource?->delete_configurations(); + } } catch (\Throwable $e) { ray($e->getMessage()); send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage()); diff --git a/app/Livewire/Project/Shared/Danger.php b/app/Livewire/Project/Shared/Danger.php index f19cf8d53..ed6695b63 100644 --- a/app/Livewire/Project/Shared/Danger.php +++ b/app/Livewire/Project/Shared/Danger.php @@ -11,6 +11,7 @@ class Danger extends Component public $resource; public $projectUuid; public $environmentName; + public bool $delete_configurations = false; public ?string $modalId = null; public function mount() @@ -25,7 +26,7 @@ public function delete() { try { $this->resource->delete(); - DeleteResourceJob::dispatch($this->resource); + DeleteResourceJob::dispatch($this->resource, $this->delete_configurations); return redirect()->route('project.resource.index', [ 'project_uuid' => $this->projectUuid, 'environment_name' => $this->environmentName diff --git a/app/Models/Application.php b/app/Models/Application.php index 1b60914a7..adb26bb21 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -57,6 +57,15 @@ protected static function booted() }); } + public function delete_configurations() + { + $server = data_get($this, 'destination.server'); + $workdir = $this->workdir(); + if (str($workdir)->endsWith($this->uuid)) { + ray('Deleting workdir'); + instant_remote_process(["rm -rf " . $this->workdir()], $server, false); + } + } public function additional_servers() { return $this->belongsToMany(Server::class, 'additional_destinations') diff --git a/app/Models/Service.php b/app/Models/Service.php index b3430ac0a..cb9d76831 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -27,6 +27,14 @@ public function tags() { return $this->morphToMany(Tag::class, 'taggable'); } + public function delete_configurations() + { + $server = data_get($this, 'server'); + $workdir = $this->workdir(); + if (str($workdir)->endsWith($this->uuid)) { + instant_remote_process(["rm -rf " . $this->workdir()], $server, false); + } + } public function status() { $applications = $this->applications; diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.php index 486372df1..6016f5ca9 100644 --- a/app/Models/StandaloneClickhouse.php +++ b/app/Models/StandaloneClickhouse.php @@ -44,7 +44,15 @@ protected static function booted() } public function workdir() { - return database_configuration_dir() . '/' . $this->uuid; + return database_configuration_dir() . "/{$this->uuid}"; + } + public function delete_configurations() + { + $server = data_get($this, 'destination.server'); + $workdir = $this->workdir(); + if (str($workdir)->endsWith($this->uuid)) { + instant_remote_process(["rm -rf " . $this->workdir()], $server, false); + } } public function realStatus() { diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.php index 7709f1f07..d83b604f2 100644 --- a/app/Models/StandaloneDragonfly.php +++ b/app/Models/StandaloneDragonfly.php @@ -42,6 +42,18 @@ protected static function booted() }); } + public function workdir() + { + return database_configuration_dir() . "/{$this->uuid}"; + } + public function delete_configurations() + { + $server = data_get($this, 'destination.server'); + $workdir = $this->workdir(); + if (str($workdir)->endsWith($this->uuid)) { + instant_remote_process(["rm -rf " . $this->workdir()], $server, false); + } + } public function realStatus() { return $this->getRawOriginal('status'); diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.php index 3194ba7ba..3bdbcfeff 100644 --- a/app/Models/StandaloneKeydb.php +++ b/app/Models/StandaloneKeydb.php @@ -42,6 +42,19 @@ protected static function booted() }); } + public function workdir() + { + return database_configuration_dir() . "/{$this->uuid}"; + } + public function delete_configurations() + { + $server = data_get($this, 'destination.server'); + $workdir = $this->workdir(); + if (str($workdir)->endsWith($this->uuid)) { + instant_remote_process(["rm -rf " . $this->workdir()], $server, false); + } + } + public function realStatus() { return $this->getRawOriginal('status'); diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php index eb465e989..d5e14b3c5 100644 --- a/app/Models/StandaloneMariadb.php +++ b/app/Models/StandaloneMariadb.php @@ -43,6 +43,18 @@ protected static function booted() $database->tags()->detach(); }); } + public function workdir() + { + return database_configuration_dir() . "/{$this->uuid}"; + } + public function delete_configurations() + { + $server = data_get($this, 'destination.server'); + $workdir = $this->workdir(); + if (str($workdir)->endsWith($this->uuid)) { + instant_remote_process(["rm -rf " . $this->workdir()], $server, false); + } + } public function realStatus() { return $this->getRawOriginal('status'); diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php index a8aab4e42..268af9403 100644 --- a/app/Models/StandaloneMongodb.php +++ b/app/Models/StandaloneMongodb.php @@ -46,6 +46,18 @@ protected static function booted() $database->tags()->detach(); }); } + public function workdir() + { + return database_configuration_dir() . "/{$this->uuid}"; + } + public function delete_configurations() + { + $server = data_get($this, 'destination.server'); + $workdir = $this->workdir(); + if (str($workdir)->endsWith($this->uuid)) { + instant_remote_process(["rm -rf " . $this->workdir()], $server, false); + } + } public function realStatus() { return $this->getRawOriginal('status'); diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php index 89155d3ec..6edbbe4b7 100644 --- a/app/Models/StandaloneMysql.php +++ b/app/Models/StandaloneMysql.php @@ -43,6 +43,18 @@ protected static function booted() $database->tags()->detach(); }); } + public function workdir() + { + return database_configuration_dir() . "/{$this->uuid}"; + } + public function delete_configurations() + { + $server = data_get($this, 'destination.server'); + $workdir = $this->workdir(); + if (str($workdir)->endsWith($this->uuid)) { + instant_remote_process(["rm -rf " . $this->workdir()], $server, false); + } + } public function realStatus() { return $this->getRawOriginal('status'); diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php index 0b7589e81..ddf33f7ed 100644 --- a/app/Models/StandalonePostgresql.php +++ b/app/Models/StandalonePostgresql.php @@ -43,6 +43,18 @@ protected static function booted() $database->tags()->detach(); }); } + public function workdir() + { + return database_configuration_dir() . "/{$this->uuid}"; + } + public function delete_configurations() + { + $server = data_get($this, 'destination.server'); + $workdir = $this->workdir(); + if (str($workdir)->endsWith($this->uuid)) { + instant_remote_process(["rm -rf " . $this->workdir()], $server, false); + } + } public function realStatus() { return $this->getRawOriginal('status'); diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php index 2b623f28d..2ab189fa4 100644 --- a/app/Models/StandaloneRedis.php +++ b/app/Models/StandaloneRedis.php @@ -38,6 +38,18 @@ protected static function booted() $database->tags()->detach(); }); } + public function workdir() + { + return database_configuration_dir() . "/{$this->uuid}"; + } + public function delete_configurations() + { + $server = data_get($this, 'destination.server'); + $workdir = $this->workdir(); + if (str($workdir)->endsWith($this->uuid)) { + instant_remote_process(["rm -rf " . $this->workdir()], $server, false); + } + } public function realStatus() { return $this->getRawOriginal('status'); diff --git a/resources/views/livewire/project/database/heading.blade.php b/resources/views/livewire/project/database/heading.blade.php index f4eadd6bf..2829d4a8d 100644 --- a/resources/views/livewire/project/database/heading.blade.php +++ b/resources/views/livewire/project/database/heading.blade.php @@ -64,7 +64,7 @@ $wire.$call('start'); }); $wire.$on('stopEvent', () => { - $wire.$dispatch('warning', 'Stopping database.'); + $wire.$dispatch('info', 'Stopping database.'); $wire.$call('stop'); }); diff --git a/resources/views/livewire/project/service/navbar.blade.php b/resources/views/livewire/project/service/navbar.blade.php index 8b727ae08..709fa2032 100644 --- a/resources/views/livewire/project/service/navbar.blade.php +++ b/resources/views/livewire/project/service/navbar.blade.php @@ -114,7 +114,7 @@ @script @endscript diff --git a/resources/views/livewire/project/shared/danger.blade.php b/resources/views/livewire/project/shared/danger.blade.php index 5c21f381d..30d370ee6 100644 --- a/resources/views/livewire/project/shared/danger.blade.php +++ b/resources/views/livewire/project/shared/danger.blade.php @@ -6,6 +6,9 @@ back! - This resource will be deleted. It is not reversible.
Please think again. +
This resource will be deleted. It is not reversible. Please think + again.

+
diff --git a/resources/views/livewire/server/proxy/deploy.blade.php b/resources/views/livewire/server/proxy/deploy.blade.php index 88ce67cec..6fcdfd9ad 100644 --- a/resources/views/livewire/server/proxy/deploy.blade.php +++ b/resources/views/livewire/server/proxy/deploy.blade.php @@ -62,7 +62,7 @@ @script