refactor: Simplify log drain installation and stop log drain if necessary
This commit is contained in:
parent
c5de1a25c3
commit
74e8a4a703
3 changed files with 25 additions and 6 deletions
|
|
@ -24,12 +24,7 @@ public function handle(Server $server)
|
|||
}
|
||||
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.');
|
||||
|
|
|
|||
20
app/Actions/Server/StopLogDrain.php
Normal file
20
app/Actions/Server/StopLogDrain.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions\Server;
|
||||
|
||||
use App\Models\Server;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class StopLogDrain
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function handle(Server $server)
|
||||
{
|
||||
try {
|
||||
return instant_remote_process(['docker rm -f coolify-log-drain || true'], $server);
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Livewire\Server;
|
||||
|
||||
use App\Actions\Server\InstallLogDrain;
|
||||
use App\Actions\Server\StopLogDrain;
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
|
||||
|
|
@ -132,6 +133,9 @@ public function submit(string $type)
|
|||
'is_logdrain_axiom_enabled' => false,
|
||||
]);
|
||||
}
|
||||
if (! $this->server->isLogDrainEnabled()) {
|
||||
StopLogDrain::dispatch($this->server);
|
||||
}
|
||||
$this->server->settings->save();
|
||||
$this->dispatch('success', 'Settings saved.');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue