@deinossrl/dgp-agent 1.4.57 → 1.4.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/index.mjs +71 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog - DGP Agent
|
|
2
2
|
|
|
3
|
+
## [1.4.59] - 2026-01-12
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Progreso en tiempo real durante pg_restore
|
|
7
|
+
- Muestra mensaje cada 10 segundos: "Restaurando... (Xs transcurridos)"
|
|
8
|
+
- Muestra tiempo total al finalizar
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Cambiado de spawnSync a spawn asíncrono para mejor feedback
|
|
12
|
+
- Mejor experiencia de usuario en restauraciones largas
|
|
13
|
+
|
|
14
|
+
## [1.4.58] - 2026-01-12
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Eliminado `--exit-on-error` por defecto en pg_restore
|
|
18
|
+
- Ahora distingue entre errores críticos y warnings de DROP
|
|
19
|
+
- Restauración continúa aunque schemas/objetos no existan previamente
|
|
20
|
+
- pg_restore crea schemas automáticamente según el backup
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- Exit code 1 con warnings se considera exitoso si no hay errores críticos
|
|
24
|
+
- Mejores logs que muestran warnings sin fallar la restauración
|
|
25
|
+
|
|
3
26
|
## [1.4.57] - 2026-01-12
|
|
4
27
|
|
|
5
28
|
### Fixed
|
package/index.mjs
CHANGED
|
@@ -2001,10 +2001,9 @@ async function executePgRestore(command) {
|
|
|
2001
2001
|
pgRestoreArgs.push('--if-exists');
|
|
2002
2002
|
}
|
|
2003
2003
|
|
|
2004
|
-
//
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
}
|
|
2004
|
+
// NO usar --exit-on-error por defecto - dejar que pg_restore continúe
|
|
2005
|
+
// Los errores de DROP son normales cuando el objeto no existe
|
|
2006
|
+
// pg_restore luego creará todo lo que necesita
|
|
2008
2007
|
|
|
2009
2008
|
pgRestoreArgs.push('--no-owner');
|
|
2010
2009
|
pgRestoreArgs.push('--no-privileges');
|
|
@@ -2012,26 +2011,86 @@ async function executePgRestore(command) {
|
|
|
2012
2011
|
// Archivo de entrada
|
|
2013
2012
|
pgRestoreArgs.push(localFilePath);
|
|
2014
2013
|
|
|
2015
|
-
// Ejecutar pg_restore
|
|
2014
|
+
// Ejecutar pg_restore con progreso en tiempo real
|
|
2016
2015
|
logCommand(`Ejecutando: pg_restore [conexión oculta]`);
|
|
2017
2016
|
await addCommandLog('command', 'Ejecutando pg_restore...');
|
|
2018
2017
|
|
|
2019
|
-
const
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2018
|
+
const startTime = Date.now();
|
|
2019
|
+
let progressInterval;
|
|
2020
|
+
|
|
2021
|
+
const result = await new Promise((resolve, reject) => {
|
|
2022
|
+
const child = spawn(pgRestorePath, pgRestoreArgs, {
|
|
2023
|
+
env: process.env,
|
|
2024
|
+
stdio: 'pipe',
|
|
2025
|
+
});
|
|
2026
|
+
|
|
2027
|
+
let stdout = '';
|
|
2028
|
+
let stderr = '';
|
|
2029
|
+
|
|
2030
|
+
child.stdout.on('data', (data) => {
|
|
2031
|
+
stdout += data.toString();
|
|
2032
|
+
});
|
|
2033
|
+
|
|
2034
|
+
child.stderr.on('data', (data) => {
|
|
2035
|
+
stderr += data.toString();
|
|
2036
|
+
});
|
|
2037
|
+
|
|
2038
|
+
// Mostrar progreso cada 10 segundos
|
|
2039
|
+
progressInterval = setInterval(() => {
|
|
2040
|
+
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
2041
|
+
logInfo(`Restaurando... (${elapsed}s transcurridos)`);
|
|
2042
|
+
}, 10000);
|
|
2043
|
+
|
|
2044
|
+
child.on('error', (error) => {
|
|
2045
|
+
clearInterval(progressInterval);
|
|
2046
|
+
reject(error);
|
|
2047
|
+
});
|
|
2048
|
+
|
|
2049
|
+
child.on('close', (code) => {
|
|
2050
|
+
clearInterval(progressInterval);
|
|
2051
|
+
resolve({ status: code, stdout, stderr });
|
|
2052
|
+
});
|
|
2023
2053
|
});
|
|
2024
2054
|
|
|
2055
|
+
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
2056
|
+
logInfo(`Restore completado en ${elapsed} segundos`);
|
|
2057
|
+
|
|
2025
2058
|
if (result.error) {
|
|
2026
2059
|
throw new Error(`Error ejecutando pg_restore: ${result.error.message}`);
|
|
2027
2060
|
}
|
|
2028
2061
|
|
|
2062
|
+
// pg_restore puede retornar exit code 1 con warnings de DROP que son normales
|
|
2063
|
+
// Verificar si es un error crítico o solo warnings
|
|
2029
2064
|
if (result.status !== 0) {
|
|
2030
|
-
const
|
|
2031
|
-
|
|
2065
|
+
const stderr = result.stderr || '';
|
|
2066
|
+
const stdout = result.stdout || '';
|
|
2067
|
+
|
|
2068
|
+
// Errores críticos que deben fallar
|
|
2069
|
+
const criticalErrors = [
|
|
2070
|
+
'could not connect',
|
|
2071
|
+
'authentication failed',
|
|
2072
|
+
'database .* does not exist',
|
|
2073
|
+
'permission denied',
|
|
2074
|
+
'out of memory'
|
|
2075
|
+
];
|
|
2076
|
+
|
|
2077
|
+
const hasCriticalError = criticalErrors.some(pattern =>
|
|
2078
|
+
new RegExp(pattern, 'i').test(stderr) || new RegExp(pattern, 'i').test(stdout)
|
|
2079
|
+
);
|
|
2080
|
+
|
|
2081
|
+
if (hasCriticalError) {
|
|
2082
|
+
throw new Error(`pg_restore failed with critical error: ${stderr}`);
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
// Si no es crítico, es un warning (DROP de objetos inexistentes, etc)
|
|
2086
|
+
logInfo(`Restauración completada con warnings (exit code ${result.status})`);
|
|
2087
|
+
if (stderr) {
|
|
2088
|
+
logInfo(`Warnings: ${stderr.substring(0, 500)}...`);
|
|
2089
|
+
}
|
|
2090
|
+
} else {
|
|
2091
|
+
logSuccess('Restauración completada sin errores');
|
|
2032
2092
|
}
|
|
2033
2093
|
|
|
2034
|
-
logSuccess('Restauración completada');
|
|
2035
2094
|
await addCommandLog('success', 'Base de datos restaurada');
|
|
2036
2095
|
|
|
2037
2096
|
// Actualizar estado en DB
|