mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-23 00:24:15 +02:00
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;
|
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);
|
DeleteService::run($this->resource);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if ($this->deleteConfigurations) {
|
||||||
|
$this->resource?->delete_configurations();
|
||||||
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
ray($e->getMessage());
|
ray($e->getMessage());
|
||||||
send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage());
|
send_internal_notification('ContainerStoppingJob failed with: ' . $e->getMessage());
|
||||||
|
@ -11,6 +11,7 @@ class Danger extends Component
|
|||||||
public $resource;
|
public $resource;
|
||||||
public $projectUuid;
|
public $projectUuid;
|
||||||
public $environmentName;
|
public $environmentName;
|
||||||
|
public bool $delete_configurations = false;
|
||||||
public ?string $modalId = null;
|
public ?string $modalId = null;
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@ -25,7 +26,7 @@ public function delete()
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->resource->delete();
|
$this->resource->delete();
|
||||||
DeleteResourceJob::dispatch($this->resource);
|
DeleteResourceJob::dispatch($this->resource, $this->delete_configurations);
|
||||||
return redirect()->route('project.resource.index', [
|
return redirect()->route('project.resource.index', [
|
||||||
'project_uuid' => $this->projectUuid,
|
'project_uuid' => $this->projectUuid,
|
||||||
'environment_name' => $this->environmentName
|
'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()
|
public function additional_servers()
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Server::class, 'additional_destinations')
|
return $this->belongsToMany(Server::class, 'additional_destinations')
|
||||||
|
@ -27,6 +27,14 @@ public function tags()
|
|||||||
{
|
{
|
||||||
return $this->morphToMany(Tag::class, 'taggable');
|
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()
|
public function status()
|
||||||
{
|
{
|
||||||
$applications = $this->applications;
|
$applications = $this->applications;
|
||||||
|
@ -44,7 +44,15 @@ protected static function booted()
|
|||||||
}
|
}
|
||||||
public function workdir()
|
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()
|
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()
|
public function realStatus()
|
||||||
{
|
{
|
||||||
return $this->getRawOriginal('status');
|
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()
|
public function realStatus()
|
||||||
{
|
{
|
||||||
return $this->getRawOriginal('status');
|
return $this->getRawOriginal('status');
|
||||||
|
@ -43,6 +43,18 @@ protected static function booted()
|
|||||||
$database->tags()->detach();
|
$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()
|
public function realStatus()
|
||||||
{
|
{
|
||||||
return $this->getRawOriginal('status');
|
return $this->getRawOriginal('status');
|
||||||
|
@ -46,6 +46,18 @@ protected static function booted()
|
|||||||
$database->tags()->detach();
|
$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()
|
public function realStatus()
|
||||||
{
|
{
|
||||||
return $this->getRawOriginal('status');
|
return $this->getRawOriginal('status');
|
||||||
|
@ -43,6 +43,18 @@ protected static function booted()
|
|||||||
$database->tags()->detach();
|
$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()
|
public function realStatus()
|
||||||
{
|
{
|
||||||
return $this->getRawOriginal('status');
|
return $this->getRawOriginal('status');
|
||||||
|
@ -43,6 +43,18 @@ protected static function booted()
|
|||||||
$database->tags()->detach();
|
$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()
|
public function realStatus()
|
||||||
{
|
{
|
||||||
return $this->getRawOriginal('status');
|
return $this->getRawOriginal('status');
|
||||||
|
@ -38,6 +38,18 @@ protected static function booted()
|
|||||||
$database->tags()->detach();
|
$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()
|
public function realStatus()
|
||||||
{
|
{
|
||||||
return $this->getRawOriginal('status');
|
return $this->getRawOriginal('status');
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
$wire.$call('start');
|
$wire.$call('start');
|
||||||
});
|
});
|
||||||
$wire.$on('stopEvent', () => {
|
$wire.$on('stopEvent', () => {
|
||||||
$wire.$dispatch('warning', 'Stopping database.');
|
$wire.$dispatch('info', 'Stopping database.');
|
||||||
$wire.$call('stop');
|
$wire.$call('stop');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -114,7 +114,7 @@
|
|||||||
@script
|
@script
|
||||||
<script>
|
<script>
|
||||||
$wire.$on('stopEvent', () => {
|
$wire.$on('stopEvent', () => {
|
||||||
$wire.$dispatch('warning', 'Stopping service.');
|
$wire.$dispatch('info', 'Stopping service.');
|
||||||
$wire.$call('stop');
|
$wire.$call('stop');
|
||||||
});
|
});
|
||||||
$wire.$on('startEvent', () => {
|
$wire.$on('startEvent', () => {
|
||||||
@ -122,12 +122,12 @@
|
|||||||
$wire.$call('start');
|
$wire.$call('start');
|
||||||
});
|
});
|
||||||
$wire.$on('restartEvent', () => {
|
$wire.$on('restartEvent', () => {
|
||||||
$wire.$dispatch('warning', 'Pulling new images.');
|
$wire.$dispatch('info', 'Pulling new images.');
|
||||||
$wire.$call('restart');
|
$wire.$call('restart');
|
||||||
});
|
});
|
||||||
$wire.on('imagePulled', () => {
|
$wire.on('imagePulled', () => {
|
||||||
window.dispatchEvent(new CustomEvent('startservice'));
|
window.dispatchEvent(new CustomEvent('startservice'));
|
||||||
$wire.$dispatch('warning', 'Restarting service.');
|
$wire.$dispatch('info', 'Restarting service.');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endscript
|
@endscript
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
back!
|
back!
|
||||||
</div>
|
</div>
|
||||||
<x-modal-confirmation isErrorButton buttonTitle="Delete">
|
<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>
|
</x-modal-confirmation>
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
@script
|
@script
|
||||||
<script>
|
<script>
|
||||||
$wire.$on('restartEvent', () => {
|
$wire.$on('restartEvent', () => {
|
||||||
$wire.$dispatch('warning', 'Restarting proxy.');
|
$wire.$dispatch('info', 'Restarting proxy.');
|
||||||
$wire.$call('restart');
|
$wire.$call('restart');
|
||||||
});
|
});
|
||||||
$wire.$on('proxyChecked', () => {
|
$wire.$on('proxyChecked', () => {
|
||||||
@ -71,7 +71,7 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
$wire.$on('stopEvent', () => {
|
$wire.$on('stopEvent', () => {
|
||||||
$wire.$dispatch('warning', 'Stopping proxy.');
|
$wire.$dispatch('info', 'Stopping proxy.');
|
||||||
$wire.$call('stop');
|
$wire.$call('stop');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user