feat: able to delete configuration from server
This commit is contained in:
parent
8b668cf8b7
commit
9032879e20
@ -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());
|
||||
|
@ -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
|
||||
|
@ -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')
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -64,7 +64,7 @@
|
||||
$wire.$call('start');
|
||||
});
|
||||
$wire.$on('stopEvent', () => {
|
||||
$wire.$dispatch('warning', 'Stopping database.');
|
||||
$wire.$dispatch('info', 'Stopping database.');
|
||||
$wire.$call('stop');
|
||||
});
|
||||
</script>
|
||||
|
@ -114,7 +114,7 @@
|
||||
@script
|
||||
<script>
|
||||
$wire.$on('stopEvent', () => {
|
||||
$wire.$dispatch('warning', 'Stopping service.');
|
||||
$wire.$dispatch('info', 'Stopping service.');
|
||||
$wire.$call('stop');
|
||||
});
|
||||
$wire.$on('startEvent', () => {
|
||||
@ -122,12 +122,12 @@
|
||||
$wire.$call('start');
|
||||
});
|
||||
$wire.$on('restartEvent', () => {
|
||||
$wire.$dispatch('warning', 'Pulling new images.');
|
||||
$wire.$dispatch('info', 'Pulling new images.');
|
||||
$wire.$call('restart');
|
||||
});
|
||||
$wire.on('imagePulled', () => {
|
||||
window.dispatchEvent(new CustomEvent('startservice'));
|
||||
$wire.$dispatch('warning', 'Restarting service.');
|
||||
$wire.$dispatch('info', 'Restarting service.');
|
||||
});
|
||||
</script>
|
||||
@endscript
|
||||
|
@ -6,6 +6,9 @@
|
||||
back!
|
||||
</div>
|
||||
<x-modal-confirmation isErrorButton buttonTitle="Delete">
|
||||
This resource will be deleted. It is not reversible. <br>Please think again.
|
||||
<div class="px-2">This resource will be deleted. It is not reversible. <strong class="text-error">Please think
|
||||
again.</strong><br><br></div>
|
||||
<x-forms.checkbox class="px-0" id="delete_configurations"
|
||||
label="Also delete configuration files from the server (/data/coolify/...)?"></x-forms.checkbox>
|
||||
</x-modal-confirmation>
|
||||
</div>
|
||||
|
@ -62,7 +62,7 @@
|
||||
@script
|
||||
<script>
|
||||
$wire.$on('restartEvent', () => {
|
||||
$wire.$dispatch('warning', 'Restarting proxy.');
|
||||
$wire.$dispatch('info', 'Restarting proxy.');
|
||||
$wire.$call('restart');
|
||||
});
|
||||
$wire.$on('proxyChecked', () => {
|
||||
@ -71,7 +71,7 @@
|
||||
|
||||
});
|
||||
$wire.$on('stopEvent', () => {
|
||||
$wire.$dispatch('warning', 'Stopping proxy.');
|
||||
$wire.$dispatch('info', 'Stopping proxy.');
|
||||
$wire.$call('stop');
|
||||
});
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user