@deinossrl/dgp-agent 1.5.6 → 1.5.7
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/index.mjs +50 -13
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1770,24 +1770,61 @@ async function executePgDump(command) {
|
|
|
1770
1770
|
// Archivo de salida
|
|
1771
1771
|
pgDumpArgs.push(`--file=${localFilePath}`);
|
|
1772
1772
|
|
|
1773
|
-
//
|
|
1773
|
+
// Agregar --verbose para obtener información de progreso
|
|
1774
|
+
pgDumpArgs.push('--verbose');
|
|
1775
|
+
|
|
1776
|
+
// Ejecutar pg_dump usando spawn para capturar progreso en tiempo real
|
|
1774
1777
|
logCommand(`Ejecutando: pg_dump [conexión oculta]`);
|
|
1775
1778
|
await addCommandLog('command', 'Ejecutando pg_dump...');
|
|
1776
1779
|
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1780
|
+
// Usar spawn asíncrono para capturar progreso
|
|
1781
|
+
await new Promise((resolve, reject) => {
|
|
1782
|
+
const pgDumpProcess = spawn(pgDumpCmd, pgDumpArgs, {
|
|
1783
|
+
env: process.env,
|
|
1784
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1785
|
+
});
|
|
1782
1786
|
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1787
|
+
let stderrBuffer = '';
|
|
1788
|
+
let stdoutBuffer = '';
|
|
1789
|
+
let lastLogTime = Date.now();
|
|
1790
|
+
|
|
1791
|
+
// Capturar stderr (pg_dump envía progreso aquí con --verbose)
|
|
1792
|
+
pgDumpProcess.stderr.on('data', (data) => {
|
|
1793
|
+
const message = data.toString();
|
|
1794
|
+
stderrBuffer += message;
|
|
1795
|
+
|
|
1796
|
+
// Enviar log cada 2 segundos para no saturar
|
|
1797
|
+
const now = Date.now();
|
|
1798
|
+
if (now - lastLogTime > 2000) {
|
|
1799
|
+
const lines = message.trim().split('\n');
|
|
1800
|
+
const relevantLine = lines[lines.length - 1];
|
|
1801
|
+
if (relevantLine.includes('processing') || relevantLine.includes('dumping') || relevantLine.includes('table')) {
|
|
1802
|
+
addCommandLog('info', `pg_dump: ${relevantLine.substring(0, 100)}`).catch(() => {});
|
|
1803
|
+
lastLogTime = now;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
});
|
|
1786
1807
|
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1808
|
+
// Capturar stdout (por si acaso)
|
|
1809
|
+
pgDumpProcess.stdout.on('data', (data) => {
|
|
1810
|
+
stdoutBuffer += data.toString();
|
|
1811
|
+
});
|
|
1812
|
+
|
|
1813
|
+
// Manejar errores del proceso
|
|
1814
|
+
pgDumpProcess.on('error', (error) => {
|
|
1815
|
+
reject(new Error(`Error ejecutando pg_dump: ${error.message}`));
|
|
1816
|
+
});
|
|
1817
|
+
|
|
1818
|
+
// Manejar finalización
|
|
1819
|
+
pgDumpProcess.on('close', (code) => {
|
|
1820
|
+
if (code !== 0) {
|
|
1821
|
+
const errorMsg = stderrBuffer || stdoutBuffer || 'Unknown error';
|
|
1822
|
+
reject(new Error(`pg_dump failed with code ${code}: ${errorMsg}`));
|
|
1823
|
+
} else {
|
|
1824
|
+
resolve();
|
|
1825
|
+
}
|
|
1826
|
+
});
|
|
1827
|
+
});
|
|
1791
1828
|
|
|
1792
1829
|
// Verificar que el archivo se creó
|
|
1793
1830
|
if (!existsSync(localFilePath)) {
|