From 74e8a4a70368979c4647beb82fb4f106b3a4f269 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 6 Aug 2024 10:52:47 +0200 Subject: [PATCH] refactor: Simplify log drain installation and stop log drain if necessary --- app/Actions/Server/InstallLogDrain.php | 7 +------ app/Actions/Server/StopLogDrain.php | 20 ++++++++++++++++++++ app/Livewire/Server/LogDrains.php | 4 ++++ 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 app/Actions/Server/StopLogDrain.php diff --git a/app/Actions/Server/InstallLogDrain.php b/app/Actions/Server/InstallLogDrain.php index 6f74e020b..034d89fe7 100644 --- a/app/Actions/Server/InstallLogDrain.php +++ b/app/Actions/Server/InstallLogDrain.php @@ -24,12 +24,7 @@ class InstallLogDrain } try { if ($type === 'none') { - $command = [ - "echo 'Stopping old Fluent Bit'", - 'docker rm -f coolify-log-drain || true', - ]; - - return instant_remote_process($command, $server); + return 'No log drain is enabled.'; } elseif ($type === 'newrelic') { if (! $server->settings->is_logdrain_newrelic_enabled) { throw new \Exception('New Relic log drain is not enabled.'); diff --git a/app/Actions/Server/StopLogDrain.php b/app/Actions/Server/StopLogDrain.php new file mode 100644 index 000000000..a5bce94a5 --- /dev/null +++ b/app/Actions/Server/StopLogDrain.php @@ -0,0 +1,20 @@ + false, ]); } + if (! $this->server->isLogDrainEnabled()) { + StopLogDrain::dispatch($this->server); + } $this->server->settings->save(); $this->dispatch('success', 'Settings saved.');