From 1bf41063aec75c2c084ed574113e199dbbcbe2cb Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 26 Oct 2025 17:08:35 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20Mailbox=20Stats=20=C3=BCber=20Dovecot=20?= =?UTF-8?q?mit=20config/mailpool.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Livewire/Ui/System/UpdateCard.php | 149 +++++++++++++++--- .../ui/system/services-card.blade.php | 2 +- 2 files changed, 132 insertions(+), 19 deletions(-) diff --git a/app/Livewire/Ui/System/UpdateCard.php b/app/Livewire/Ui/System/UpdateCard.php index 25a63e8..0a9cdf3 100644 --- a/app/Livewire/Ui/System/UpdateCard.php +++ b/app/Livewire/Ui/System/UpdateCard.php @@ -85,6 +85,45 @@ class UpdateCard extends Component $this->recomputeUi(); } +// public function pollUpdate(): void +// { +// $this->refreshLowLevelState(); +// +// $started = (int) Cache::get($this->cacheStartedAtKey, 0); +// if ($this->running && $started > 0 && (time() - $started) > $this->failsafeSeconds) { +// $this->running = false; +// $this->rc ??= 0; // failsafe: als erfolgreich werten +// } +// +// if (!$this->running) { +// Cache::forget($this->cacheStartedAtKey); +// +// $this->reloadVersionsAndStatus(); +// $this->recompute(); +// +// if ($this->rc === 0 && !$this->postActionsDone) { +// // Restarts DE-coupled +// @shell_exec('nohup php /var/www/mailwolt/artisan mailwolt:restart-services >/dev/null 2>&1 &'); +// $this->postActionsDone = true; +// +// $ver = $this->displayCurrent ?? 'aktuelle Version'; +// $this->progressLine = ''; +// $this->dispatch('toast', type: 'success', title: 'Update erfolgreich', +// text: "MailWolt wurde auf {$ver} aktualisiert.", badge: 'System', duration: 4000); +// $this->dispatch('reload-page', delay: 5000); +// } elseif ($this->rc !== null && $this->rc !== 0 && !$this->postActionsDone) { +// $this->postActionsDone = true; +// $this->errorLine = "Update fehlgeschlagen (rc={$this->rc})."; +// $this->dispatch('toast', type: 'error', title: 'Update fehlgeschlagen', +// text: $this->progressLine ?: 'Bitte /var/log/mailwolt-update.log prüfen', badge: 'System', duration: -1); +// } +// +// $this->state = 'idle'; +// } +// +// $this->recomputeUi(); +// } + // public function pollUpdate(): void // { // // 1) aktuellen Wrapper-Status einlesen @@ -140,42 +179,59 @@ class UpdateCard extends Component // $this->recomputeUi(); // } + public function pollUpdate(): void { + // 1) aktuellen Wrapper-Status einlesen $this->refreshLowLevelState(); - $started = (int) Cache::get($this->cacheStartedAtKey, 0); + // 2) Failsafe + $started = (int)Cache::get($this->cacheStartedAtKey, 0); if ($this->running && $started > 0 && (time() - $started) > $this->failsafeSeconds) { $this->running = false; - $this->rc ??= 0; // failsafe: als erfolgreich werten + $this->rc ??= 0; // wenn unklar, als erfolgreich werten } + // 3) Abschluss? if (!$this->running) { Cache::forget($this->cacheStartedAtKey); + // Nachlauf: Versionen & Vergleich neu aufbauen $this->reloadVersionsAndStatus(); $this->recompute(); if ($this->rc === 0 && !$this->postActionsDone) { - // Restarts DE-coupled + // Dienste neu starten (asynchron) @shell_exec('nohup php /var/www/mailwolt/artisan mailwolt:restart-services >/dev/null 2>&1 &'); $this->postActionsDone = true; $ver = $this->displayCurrent ?? 'aktuelle Version'; $this->progressLine = ''; - $this->dispatch('toast', type: 'success', title: 'Update erfolgreich', - text: "MailWolt wurde auf {$ver} aktualisiert.", badge: 'System', duration: 4000); $this->dispatch('reload-page', delay: 5000); + $this->dispatch('toast', + type: 'success', + title: 'Update erfolgreich', + text: "MailWolt wurde auf {$ver} aktualisiert.", + badge: 'System', + duration: 4000 + ); } elseif ($this->rc !== null && $this->rc !== 0 && !$this->postActionsDone) { + // Fehlerfall $this->postActionsDone = true; $this->errorLine = "Update fehlgeschlagen (rc={$this->rc})."; - $this->dispatch('toast', type: 'error', title: 'Update fehlgeschlagen', - text: $this->progressLine ?: 'Bitte /var/log/mailwolt-update.log prüfen', badge: 'System', duration: -1); + $this->dispatch('toast', + type: 'error', + title: 'Update fehlgeschlagen', + text: $this->progressLine ?: 'Bitte Logs prüfen: /var/log/mailwolt-update.log', + badge: 'System', + duration: 0 + ); } $this->state = 'idle'; } + // UI bei jedem Poll neu ableiten $this->recomputeUi(); } @@ -269,17 +325,6 @@ class UpdateCard extends Component } -// protected function refreshLowLevelState(): void -// { -// $state = @trim(@file_get_contents('/var/lib/mailwolt/update/state') ?: ''); -// $this->running = ($state === 'running'); -// -// $rcRaw = @trim(@file_get_contents('/var/lib/mailwolt/update/rc') ?: ''); -// $this->rc = is_numeric($rcRaw) ? (int)$rcRaw : null; -// -// $this->progressLine = $this->tailUpdateLog(); -// } - protected function refreshLowLevelState(): void { $state = @trim(@file_get_contents('/var/lib/mailwolt/update/state') ?: ''); @@ -350,6 +395,74 @@ class UpdateCard extends Component } } + +// public function pollUpdate(): void +// { +// // 1) aktuellen Wrapper-Status einlesen +// $this->refreshLowLevelState(); +// +// // 2) Failsafe +// $started = (int)Cache::get($this->cacheStartedAtKey, 0); +// if ($this->running && $started > 0 && (time() - $started) > $this->failsafeSeconds) { +// $this->running = false; +// $this->rc ??= 0; // wenn unklar, als erfolgreich werten +// } +// +// // 3) Abschluss? +// if (!$this->running) { +// Cache::forget($this->cacheStartedAtKey); +// +// // Nachlauf: Versionen & Vergleich neu aufbauen +// $this->reloadVersionsAndStatus(); +// $this->recompute(); +// +// if ($this->rc === 0 && !$this->postActionsDone) { +// // Dienste neu starten (asynchron) +// @shell_exec('nohup php /var/www/mailwolt/artisan mailwolt:restart-services >/dev/null 2>&1 &'); +// $this->postActionsDone = true; +// +// $ver = $this->displayCurrent ?? 'aktuelle Version'; +// $this->progressLine = ''; +// $this->dispatch('reload-page', delay: 5000); +// $this->dispatch('toast', +// type: 'success', +// title: 'Update erfolgreich', +// text: "MailWolt wurde auf {$ver} aktualisiert.", +// badge: 'System', +// duration: 4000 +// ); +// } elseif ($this->rc !== null && $this->rc !== 0 && !$this->postActionsDone) { +// // Fehlerfall +// $this->postActionsDone = true; +// $this->errorLine = "Update fehlgeschlagen (rc={$this->rc})."; +// $this->dispatch('toast', +// type: 'error', +// title: 'Update fehlgeschlagen', +// text: $this->progressLine ?: 'Bitte Logs prüfen: /var/log/mailwolt-update.log', +// badge: 'System', +// duration: 0 +// ); +// } +// +// $this->state = 'idle'; +// } +// +// // UI bei jedem Poll neu ableiten +// $this->recomputeUi(); +// } + +// protected function refreshLowLevelState(): void +// { +// $state = @trim(@file_get_contents('/var/lib/mailwolt/update/state') ?: ''); +// $this->running = ($state === 'running'); +// +// $rcRaw = @trim(@file_get_contents('/var/lib/mailwolt/update/rc') ?: ''); +// $this->rc = is_numeric($rcRaw) ? (int)$rcRaw : null; +// +// $this->progressLine = $this->tailUpdateLog(); +// } + + //namespace App\Livewire\Ui\System; // //use Illuminate\Support\Facades\Artisan; diff --git a/resources/views/livewire/ui/system/services-card.blade.php b/resources/views/livewire/ui/system/services-card.blade.php index a3e8679..41fd03c 100644 --- a/resources/views/livewire/ui/system/services-card.blade.php +++ b/resources/views/livewire/ui/system/services-card.blade.php @@ -5,7 +5,7 @@ Dienste - +