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
boban 2026-04-26 21:00:33 +02:00
parent d0e1d5613c
commit 029d959d51
2 changed files with 27 additions and 1 deletions

25
app/Jobs/ClamavEnable.php Normal file
View File

@ -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));
}
}
}

View File

@ -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".';
} }