From 72890e37d964720a8327915efd2a73ebfb545d52 Mon Sep 17 00:00:00 2001 From: Milton Gonzalez Date: Fri, 23 Oct 2026 14:25:49 -0500 Subject: [PATCH] fix: version 3.1.1 -- Actualizador no queda colgado al reiniciar el backend Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 8 ++++++++ VERSION | 2 +- backend/package.json | 2 +- frontend/package.json | 2 +- frontend/src/pages/Configuracion/UpdaterPanel.jsx | 11 ++++++++--- scripts/apply-update.sh | 8 +++++--- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52b9427..e8257a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog - project.linkedcorp.net +## [3.1.1] - 2026-10-23 +### Fixed +- El popup de actualización quedaba en "Reiniciando servicios" hasta agotar los 10 minutos: el + script corre en el cgroup del backend y al reiniciarlo systemd lo mataba antes de marcar el fin. + Ahora reinicia el frontend primero, marca el fin y reinicia el backend al final; el popup da por + terminado cuando el backend ya reiniciado reporta la versión nueva y el frontend sirve la misma. +- El porcentaje del popup avanza según la fase real del script, no por tiempo transcurrido. + ## [3.1.0] - 2026-10-23 ### Added - Acceso por módulo y por usuario: el superadmin, desde Organización → Usuarios → menú de la diff --git a/VERSION b/VERSION index fd2a018..94ff29c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.0 +3.1.1 diff --git a/backend/package.json b/backend/package.json index 4bf63da..9ff42af 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "project-linkedcorp-backend", - "version": "3.1.0", + "version": "3.1.1", "private": true, "type": "module", "main": "src/server.js", diff --git a/frontend/package.json b/frontend/package.json index e6718dd..a5d5b6e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "project-linkedcorp-frontend", "private": true, - "version": "3.1.0", + "version": "3.1.1", "type": "module", "scripts": { "dev": "vite", diff --git a/frontend/src/pages/Configuracion/UpdaterPanel.jsx b/frontend/src/pages/Configuracion/UpdaterPanel.jsx index 9ca9d38..d9e0217 100644 --- a/frontend/src/pages/Configuracion/UpdaterPanel.jsx +++ b/frontend/src/pages/Configuracion/UpdaterPanel.jsx @@ -18,6 +18,9 @@ const PHASE_KEYS = { complete: 'updater_phase_verify', }; +// Avance por fase real del script (no por tiempo). El 100% solo llega al confirmar las versiones. +const PHASE_PCT = { backup: 10, source: 20, backend: 40, frontend: 65, publish: 85, restart: 90, complete: 95 }; + export default function UpdaterPanel() { const { t, openDialog } = useUi(); const { data: status, loading, error, reload } = useAsync(getUpdateStatus, []); @@ -36,7 +39,9 @@ export default function UpdaterPanel() { return () => { mountedRef.current = false; }; }, []); - // El estado del script confirma el final; ambas versiones comprueban lo que realmente se sirve. + // Termina cuando el backend YA reiniciado reporta la version nueva (runningVersion se lee al + // arrancar el proceso) y el frontend sirve la misma. No depende de la marca "done" del script: + // al reiniciar el backend, systemd puede matar al script (corre en el cgroup del backend). async function pollUntilReady(targetVersion, startedAt) { if (pollingRef.current) return; pollingRef.current = true; @@ -46,16 +51,16 @@ export default function UpdaterPanel() { while (mountedRef.current && Date.now() - startedAt < POLL_TIMEOUT_MS) { await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS)); if (!mountedRef.current) return; - setProgressPct(Math.min(95, Math.round(((Date.now() - startedAt) / POLL_TIMEOUT_MS) * 100))); try { const progress = await getApplyProgress(); if (progress.targetVersion !== targetVersion) continue; setPhase(progress.phase); + setProgressPct((pct) => Math.max(pct, PHASE_PCT[progress.phase] ?? pct)); if (progress.state === 'failed') { setApplyError(t('updater_apply_failed')); return; } - if (progress.state === 'done' && progress.runningVersion === targetVersion) { + if (progress.runningVersion === targetVersion) { const frontendVersion = await getFrontendVersion(); if (frontendVersion !== targetVersion) continue; setProgressPct(100); diff --git a/scripts/apply-update.sh b/scripts/apply-update.sh index 8830c70..92347d8 100755 --- a/scripts/apply-update.sh +++ b/scripts/apply-update.sh @@ -82,9 +82,11 @@ write_status running # matchea ninguna de las dos reglas, sudo pide contraseña, falla en este contexto sin terminal, y # el restart nunca pasa (el resto del update ya corrio bien, pero los servicios quedan con el # codigo viejo sin que nada avise del error). Bug real encontrado el 2026-09-30. -sudo systemctl restart "$BACKEND_SERVICE" +# Frontend primero y backend AL FINAL: este script corre dentro del cgroup del backend, asi que +# reiniciarlo lo mata. Por eso se marca "done" antes; el popup confirma igual que el backend nuevo +# este arriba (runningVersion) antes de recargar. sudo systemctl restart "$FRONTEND_SERVICE" - PHASE=complete write_status done -echo "=== update done $(date -Iseconds) -- v$NEW_VERSION ===" +echo "=== update done $(date -Iseconds) -- v$NEW_VERSION (reiniciando backend) ===" +sudo systemctl restart "$BACKEND_SERVICE"