diff --git a/app/Services/DeploymentService.php b/app/Services/DeploymentService.php index 12ba19e..de90114 100644 --- a/app/Services/DeploymentService.php +++ b/app/Services/DeploymentService.php @@ -260,7 +260,7 @@ class DeploymentService return null; } $data = json_decode((string) @file_get_contents($path), true); - if (! is_array($data) || ! in_array($data['stage'] ?? null, ['fetch', 'build', 'restart', 'migrate', 'done'], true)) { + if (! is_array($data) || ! in_array($data['stage'] ?? null, ['fetch', 'build', 'restart', 'migrate', 'done', 'error'], true)) { return null; } // Require a real timestamp: the progress page's freshness logic ties a stage to THIS update diff --git a/docker/restart-sentinel/watch.sh b/docker/restart-sentinel/watch.sh index a032fc4..caa58f7 100755 --- a/docker/restart-sentinel/watch.sh +++ b/docker/restart-sentinel/watch.sh @@ -35,6 +35,17 @@ COMPOSE_FILE="${CLUSEV_DIR}/docker-compose.prod.yml" TAG="clusev-restart" log() { printf '%s %s: %s\n' "$(date -Is)" "$TAG" "$*"; } +# Publish an "error" stage to the update-progress feed (run/update-phase.json, bind-mounted into the +# app container) so the browser shows the failure AT ONCE instead of spinning to its 10-minute +# timeout. Best-effort — a write failure must never change the update's outcome. +write_update_error() { + local f="${CLUSEV_DIR}/run/update-phase.json" + mkdir -p "${CLUSEV_DIR}/run" 2>/dev/null || true + printf '{"stage":"error","at":%s}\n' "$(date +%s 2>/dev/null || echo 0)" > "$f" 2>/dev/null || true + chmod 644 "$f" 2>/dev/null || true + return 0 +} + # Restart the stack and consume the sentinel. `up -d` (not bare `restart`) so a # changed image/config is also applied and any down service is brought back. do_restart() { @@ -68,19 +79,34 @@ run_once() { # needs root for docker/systemd/apt. do_update() { TAG="clusev-update" - [ -f "$COMPOSE_FILE" ] || { log "compose file not found: $COMPOSE_FILE — skipping"; return 1; } + # Every failure path below publishes the error stage too, so a page opened by the dashboard never + # spins to the timeout when the update can't even start. + [ -f "$COMPOSE_FILE" ] || { log "compose file not found: $COMPOSE_FILE — skipping"; write_update_error; return 1; } local updater="${CLUSEV_DIR}/update.sh" if [ ! -f "$updater" ]; then log "update.sh not found at $updater — clearing sentinel, nothing to do" rm -f "$CLUSEV_UPDATE_SIGNAL" + write_update_error return 1 fi rm -f "$CLUSEV_UPDATE_SIGNAL" && log "update sentinel consumed: $CLUSEV_UPDATE_SIGNAL" log "update requested — running update.sh in ${CLUSEV_DIR}" - if bash "$updater"; then + # Tee the whole run to a host log the operator can inspect, and cap it with a generous timeout so + # a truly-stuck step (e.g. a hung build) fails LOUDLY rather than pinning the progress page. On ANY + # non-zero exit (update.sh or its exec'd install.sh — the exit code propagates through exec) publish + # the error stage so the browser stops spinning and shows the failure. `timeout` exit 124 = capped. + local logf="${CLUSEV_DIR}/run/update.log" rc=0 + mkdir -p "${CLUSEV_DIR}/run" 2>/dev/null || true + timeout -k 30 1800 bash "$updater" 2>&1 | tee "$logf" || rc=${PIPESTATUS[0]} + if [ "$rc" = 0 ]; then log "update applied" else - log "update.sh FAILED — see output above; re-trigger from the dashboard to retry" + if [ "$rc" = 124 ]; then + log "update.sh TIMED OUT after 30m — see $logf; re-trigger from the dashboard to retry" + else + log "update.sh FAILED (exit $rc) — see $logf and the journal; re-trigger from the dashboard to retry" + fi + write_update_error return 1 fi } diff --git a/lang/de/update.php b/lang/de/update.php index 3090422..d98d0ff 100644 --- a/lang/de/update.php +++ b/lang/de/update.php @@ -18,4 +18,9 @@ return [ 'timeout_heading' => 'Update dauert ungewöhnlich lange', 'timeout_hint' => 'Bitte die Seite manuell neu laden oder die Logs prüfen (journalctl -u clusev-update.service).', 'reload_button' => 'Neu laden', + + // Fehler — der Host-Updater ist mit Fehler beendet (git pull, Build oder Migration) oder im Timeout. + 'error_heading' => 'Update fehlgeschlagen', + 'error_hint' => 'Der Stack konnte nicht aktualisiert werden — die bisherige Version läuft weiter. Ursache im Host-Log prüfen (journalctl -u clusev-update.service, oder run/update.log), beheben und das Update erneut über das Dashboard auslösen.', + 'back_button' => 'Zurück', ]; diff --git a/lang/en/update.php b/lang/en/update.php index cba1c9c..2f664ed 100644 --- a/lang/en/update.php +++ b/lang/en/update.php @@ -18,4 +18,9 @@ return [ 'timeout_heading' => 'Update is taking unusually long', 'timeout_hint' => 'Please reload the page manually or check the logs (journalctl -u clusev-update.service).', 'reload_button' => 'Reload', + + // Error — the host updater exited non-zero (git pull, build or migrate failed) or timed out. + 'error_heading' => 'Update failed', + 'error_hint' => 'The stack could not be updated — your previous version is still running. Check the host log for the cause (journalctl -u clusev-update.service, or run/update.log), fix it, then re-trigger the update from the dashboard.', + 'back_button' => 'Back', ]; diff --git a/resources/views/update-progress.blade.php b/resources/views/update-progress.blade.php index d24f01b..7d7fc59 100644 --- a/resources/views/update-progress.blade.php +++ b/resources/views/update-progress.blade.php @@ -63,6 +63,23 @@ {{ __('update.reload_button') }} + + {{-- Error: the host updater exited non-zero (or timed out). Surfaced by the + update-status feed reporting stage=error, so the page stops at once instead + of spinning to the 10-minute timeout. The previous version keeps running. --}} +
{{ __('update.error_hint') }}
+ +