parent
e23713a5c6
commit
d200e3e73f
|
|
@ -18,6 +18,7 @@ class UpdateCard extends Component
|
|||
|
||||
public string $state = 'idle'; // idle | running
|
||||
public bool $running = false; // low-level Wrapper-Status
|
||||
public ?string $lowState = null; // 'running' | 'done' | '' (unbekannt)
|
||||
public ?int $rc = null; // Rückgabecode vom Wrapper
|
||||
|
||||
/* ===== UI-Properties (nur fürs Blade) ===== */
|
||||
|
|
@ -93,27 +94,24 @@ class UpdateCard extends Component
|
|||
}
|
||||
|
||||
// 2) Failsafe
|
||||
$started = (int)Cache::get($this->cacheStartedAtKey, 0);
|
||||
$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
|
||||
$this->lowState = 'done';
|
||||
$this->rc ??= 0;
|
||||
}
|
||||
|
||||
// 3) Abschluss?
|
||||
if (!$this->running) {
|
||||
// Abschluss NUR wenn state=done
|
||||
if ($this->lowState === 'done') {
|
||||
Cache::forget($this->cacheStartedAtKey);
|
||||
|
||||
usleep(500_000);
|
||||
// Nachlauf: Versionen & Vergleich neu aufbauen
|
||||
// kurze Gnadenzeit gegen Schreibpuffer
|
||||
usleep(300_000);
|
||||
|
||||
$this->reloadVersionsAndStatus();
|
||||
$this->recompute();
|
||||
|
||||
if ($this->current && $this->latest && version_compare($this->current, $this->latest, '>=')) {
|
||||
$this->hasUpdate = false;
|
||||
}
|
||||
|
||||
if ($this->rc === 0 && !$this->postActionsDone) {
|
||||
// @shell_exec('nohup php /var/www/mailwolt/artisan mailwolt:restart-services >/dev/null 2>&1 &');
|
||||
@shell_exec('nohup php /var/www/mailwolt/artisan health:collect >/dev/null 2>&1 &');
|
||||
@shell_exec('nohup php /var/www/mailwolt/artisan settings:sync >/dev/null 2>&1 &');
|
||||
@shell_exec('nohup php /var/www/mailwolt/artisan spamav:collect >/dev/null 2>&1 &');
|
||||
|
|
@ -121,32 +119,76 @@ class UpdateCard extends Component
|
|||
|
||||
$ver = $this->displayCurrent ?? 'aktuelle Version';
|
||||
$this->progressLine = 'Update abgeschlossen: ' . $ver;
|
||||
// $this->dispatch('reload-page', delay: 5000);
|
||||
$this->dispatch('toast',
|
||||
type: 'success',
|
||||
title: 'Update erfolgreich',
|
||||
text: "MailWolt wurde auf {$ver} aktualisiert.",
|
||||
badge: 'System',
|
||||
duration: 4000
|
||||
);
|
||||
|
||||
$this->dispatch('reload-page', delay: 5000);
|
||||
|
||||
// Optional: NICHT sofort reloaden – Nutzer entscheidet
|
||||
// $this->dispatch('reload-page', delay: 6000);
|
||||
} 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->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';
|
||||
}
|
||||
|
||||
$this->recomputeUi();
|
||||
|
||||
// 3) Abschluss?
|
||||
// $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
|
||||
// }
|
||||
|
||||
// if (!$this->running) {
|
||||
// Cache::forget($this->cacheStartedAtKey);
|
||||
//
|
||||
// usleep(500_000);
|
||||
// // Nachlauf: Versionen & Vergleich neu aufbauen
|
||||
// $this->reloadVersionsAndStatus();
|
||||
// $this->recompute();
|
||||
//
|
||||
// if ($this->current && $this->latest && version_compare($this->current, $this->latest, '>=')) {
|
||||
// $this->hasUpdate = false;
|
||||
// }
|
||||
//
|
||||
// if ($this->rc === 0 && !$this->postActionsDone) {
|
||||
//// @shell_exec('nohup php /var/www/mailwolt/artisan mailwolt:restart-services >/dev/null 2>&1 &');
|
||||
// @shell_exec('nohup php /var/www/mailwolt/artisan health:collect >/dev/null 2>&1 &');
|
||||
// @shell_exec('nohup php /var/www/mailwolt/artisan settings:sync >/dev/null 2>&1 &');
|
||||
// @shell_exec('nohup php /var/www/mailwolt/artisan spamav:collect >/dev/null 2>&1 &');
|
||||
// $this->postActionsDone = true;
|
||||
//
|
||||
// $ver = $this->displayCurrent ?? 'aktuelle Version';
|
||||
// $this->progressLine = 'Update abgeschlossen: ' . $ver;
|
||||
//// $this->dispatch('reload-page', delay: 5000);
|
||||
// $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) {
|
||||
// // 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';
|
||||
// }
|
||||
// $this->recomputeUi();
|
||||
}
|
||||
|
||||
/* ================== Helpers ================== */
|
||||
|
|
@ -239,22 +281,38 @@ class UpdateCard extends Component
|
|||
|
||||
}
|
||||
|
||||
// protected function refreshLowLevelState(): void
|
||||
// {
|
||||
// $state = @trim(@file_get_contents('/var/lib/mailwolt/update/state') ?: '');
|
||||
// $rcRaw = @trim(@file_get_contents('/var/lib/mailwolt/update/rc') ?: '');
|
||||
//
|
||||
// $this->rc = is_numeric($rcRaw) ? (int)$rcRaw : null;
|
||||
// $this->running = ($this->rc === null) && ($state !== 'done');
|
||||
// $this->progressLine = $this->tailUpdateLog();
|
||||
//
|
||||
//// $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') ?: '');
|
||||
$rcRaw = @trim(@file_get_contents('/var/lib/mailwolt/update/rc') ?: '');
|
||||
|
||||
$this->rc = is_numeric($rcRaw) ? (int)$rcRaw : null;
|
||||
$this->running = ($this->rc === null) && ($state !== 'done');
|
||||
$this->progressLine = $this->tailUpdateLog();
|
||||
$this->lowState = $state !== '' ? $state : null;
|
||||
|
||||
// $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();
|
||||
// running: solange NICHT 'done'
|
||||
$this->running = ($this->lowState !== 'done');
|
||||
|
||||
// rc erst freigeben, wenn wirklich done
|
||||
$this->rc = ($this->lowState === 'done' && is_numeric($rcRaw)) ? (int)$rcRaw : null;
|
||||
|
||||
$this->progressLine = $this->tailUpdateLog();
|
||||
}
|
||||
|
||||
protected function readCurrentVersion(): ?string
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{{-- Progress --}}
|
||||
<div class="mb-3">
|
||||
<div class="h-2 bg-white/10 rounded overflow-hidden">
|
||||
|
|
|
|||
Loading…
Reference in New Issue