Fix: ClamAV enable via Queue Job statt shell_exec im Web-Request
nohup/shell_exec wird von PHP-FPM-Prozessgroup nach Request-Ende gekillt. ClamavEnable Job läuft im Queue-Worker und blockiert nicht den Web-Request. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>main v1.1.335
parent
d0e1d5613c
commit
029d959d51
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ClamavEnable implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public int $timeout = 120;
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
exec('sudo -n /usr/local/sbin/mailwolt-clamav enable 2>&1', $out, $rc);
|
||||||
|
\Log::info('ClamavEnable job', ['rc' => $rc, 'out' => $out]);
|
||||||
|
if ($rc !== 0) {
|
||||||
|
throw new \RuntimeException('mailwolt-clamav enable failed (rc=' . $rc . '): ' . implode(' ', $out));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Livewire\Ui\Security;
|
namespace App\Livewire\Ui\Security;
|
||||||
|
|
||||||
|
use App\Jobs\ClamavEnable;
|
||||||
use Livewire\Attributes\Layout;
|
use Livewire\Attributes\Layout;
|
||||||
use Livewire\Attributes\Title;
|
use Livewire\Attributes\Title;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
@ -55,7 +56,7 @@ class ClamavManager extends Component
|
||||||
{
|
{
|
||||||
$this->lastError = '';
|
$this->lastError = '';
|
||||||
$this->lastSuccess = '';
|
$this->lastSuccess = '';
|
||||||
@shell_exec('nohup sudo -n /usr/local/sbin/mailwolt-clamav enable </dev/null >/tmp/mw-clamav-start.log 2>&1 &');
|
ClamavEnable::dispatch();
|
||||||
$this->enabled = true;
|
$this->enabled = true;
|
||||||
$this->lastSuccess = 'ClamAV wird gestartet… Dies kann bis zu 60 Sekunden dauern. Klicken Sie danach auf „Aktualisieren".';
|
$this->lastSuccess = 'ClamAV wird gestartet… Dies kann bis zu 60 Sekunden dauern. Klicken Sie danach auf „Aktualisieren".';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue