@deinossrl/dgp-agent 1.5.12 → 1.5.13
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 +6 -0
- package/index.mjs +49 -25
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog - DGP Agent
|
|
2
2
|
|
|
3
|
+
## [1.5.13] - 2026-01-13
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- **Logs en tiempo real mejorados**: Desacoplado el log local del log web. Ahora la consola muestra *toda* la actividad de pg_dump/pg_restore inmediatamente (conectando, leyendo schemas, etc.), no solo cuando procesa tablas.
|
|
7
|
+
- Los mensajes repetitivos (bulk data) siguen limitados a uno cada 2 segundos para no saturar, pero los mensajes de estado iniciales son instantáneos.
|
|
8
|
+
|
|
3
9
|
## [1.5.12] - 2026-01-13
|
|
4
10
|
|
|
5
11
|
### Added
|
package/index.mjs
CHANGED
|
@@ -1809,7 +1809,8 @@ async function executePgDump(command) {
|
|
|
1809
1809
|
|
|
1810
1810
|
let stderrBuffer = '';
|
|
1811
1811
|
let stdoutBuffer = '';
|
|
1812
|
-
let lastLogTime =
|
|
1812
|
+
let lastLogTime = 0; // Para consola local
|
|
1813
|
+
let lastLogTimeWeb = 0; // Para web
|
|
1813
1814
|
let objectCount = 0;
|
|
1814
1815
|
let totalEstimated = 0;
|
|
1815
1816
|
|
|
@@ -1826,33 +1827,44 @@ async function executePgDump(command) {
|
|
|
1826
1827
|
const message = data.toString();
|
|
1827
1828
|
stderrBuffer += message;
|
|
1828
1829
|
|
|
1829
|
-
// Contar objetos procesados
|
|
1830
1830
|
const lines = message.split('\n');
|
|
1831
1831
|
for (const line of lines) {
|
|
1832
|
-
|
|
1832
|
+
const trimmed = line.trim();
|
|
1833
|
+
if (!trimmed) continue;
|
|
1834
|
+
|
|
1835
|
+
// LOGICA LOCAL: Mostrar actividad en consola
|
|
1836
|
+
// Si es un mensaje de "loop" (procesando datos), solo mostrar si pasó tiempo
|
|
1837
|
+
const isLoopMessage = trimmed.includes('dumping data') || trimmed.includes('processing data');
|
|
1838
|
+
const now = Date.now();
|
|
1839
|
+
|
|
1840
|
+
if (!isLoopMessage || now - lastLogTime > 2000) {
|
|
1841
|
+
console.log(`${colors.gray}[pg_dump] ${trimmed}${colors.reset}`);
|
|
1842
|
+
if (isLoopMessage) lastLogTime = now;
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
// LOGICA WEB: Filtrar y contar para la UI
|
|
1846
|
+
if (trimmed.includes('processing') || trimmed.includes('dumping data for table') || trimmed.includes('creating') || trimmed.includes('setting owner')) {
|
|
1833
1847
|
objectCount++;
|
|
1834
1848
|
}
|
|
1835
1849
|
}
|
|
1836
1850
|
|
|
1837
|
-
// Enviar log cada 2 segundos para no saturar
|
|
1851
|
+
// Enviar log a la WEB cada 2 segundos para no saturar
|
|
1838
1852
|
const now = Date.now();
|
|
1839
|
-
if (now -
|
|
1840
|
-
|
|
1841
|
-
|
|
1853
|
+
if (now - lastLogTimeWeb > 2000) {
|
|
1854
|
+
// ... lógica web existente ...
|
|
1855
|
+
const relevantLine = lines.reverse().find(l => l.includes('processing') || l.includes('dumping') || l.includes('table'));
|
|
1856
|
+
if (relevantLine) {
|
|
1857
|
+
// Solo enviamos a la web, local ya se mostró arriba
|
|
1842
1858
|
let progressMsg = '';
|
|
1843
|
-
|
|
1844
|
-
// Si tenemos estimación, mostrar porcentaje
|
|
1845
1859
|
if (totalEstimated > 0 && objectCount > 0) {
|
|
1846
1860
|
const percentage = Math.min(Math.round((objectCount / totalEstimated) * 100), 100);
|
|
1847
|
-
progressMsg = `Progreso: ${percentage}% (${objectCount}/${totalEstimated})
|
|
1848
|
-
} else
|
|
1849
|
-
progressMsg = `Objetos procesados: ${objectCount}
|
|
1861
|
+
progressMsg = `Progreso: ${percentage}% (${objectCount}/${totalEstimated})`;
|
|
1862
|
+
} else {
|
|
1863
|
+
progressMsg = `Objetos procesados: ${objectCount}`;
|
|
1850
1864
|
}
|
|
1851
|
-
|
|
1852
|
-
progressMsg += relevantLine.substring(0, 80);
|
|
1853
|
-
logInfo(progressMsg); // Muestra en consola local
|
|
1865
|
+
progressMsg += ` - ${relevantLine.substring(0, 50)}...`;
|
|
1854
1866
|
addCommandLog('info', progressMsg).catch(() => { });
|
|
1855
|
-
|
|
1867
|
+
lastLogTimeWeb = now;
|
|
1856
1868
|
}
|
|
1857
1869
|
}
|
|
1858
1870
|
});
|
|
@@ -2315,7 +2327,8 @@ async function executePgRestore(command) {
|
|
|
2315
2327
|
let stdout = '';
|
|
2316
2328
|
let stderr = '';
|
|
2317
2329
|
let processedObjects = 0;
|
|
2318
|
-
let lastLogTime =
|
|
2330
|
+
let lastLogTime = 0;
|
|
2331
|
+
let lastLogTimeWeb = 0;
|
|
2319
2332
|
|
|
2320
2333
|
child.stdout.on('data', (data) => {
|
|
2321
2334
|
stdout += data.toString();
|
|
@@ -2325,15 +2338,26 @@ async function executePgRestore(command) {
|
|
|
2325
2338
|
const message = data.toString();
|
|
2326
2339
|
stderr += message;
|
|
2327
2340
|
|
|
2328
|
-
// Contar objetos procesados buscando patrones como "processing item" o nombres de tablas
|
|
2329
2341
|
const lines = message.split('\n');
|
|
2330
2342
|
for (const line of lines) {
|
|
2331
|
-
|
|
2343
|
+
const trimmed = line.trim();
|
|
2344
|
+
if (!trimmed) continue;
|
|
2345
|
+
|
|
2346
|
+
// LOGICA LOCAL: Mostrar actividad en consola
|
|
2347
|
+
const isLoopMessage = trimmed.includes('processing item') || trimmed.includes('processing data');
|
|
2348
|
+
const now = Date.now();
|
|
2349
|
+
|
|
2350
|
+
if (!isLoopMessage || now - lastLogTime > 2000) {
|
|
2351
|
+
console.log(`${colors.gray}[pg_restore] ${trimmed}${colors.reset}`);
|
|
2352
|
+
if (isLoopMessage) lastLogTime = now;
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
// LOGICA WEB
|
|
2356
|
+
if (trimmed.includes('processing') || trimmed.includes('creating') || trimmed.includes('restoring')) {
|
|
2332
2357
|
processedObjects++;
|
|
2333
2358
|
|
|
2334
|
-
// Enviar log cada 2 segundos para no saturar
|
|
2335
|
-
|
|
2336
|
-
if (now - lastLogTime > 2000) {
|
|
2359
|
+
// Enviar log WEB cada 2 segundos para no saturar
|
|
2360
|
+
if (now - lastLogTimeWeb > 2000) {
|
|
2337
2361
|
let progressMsg = '';
|
|
2338
2362
|
|
|
2339
2363
|
if (totalObjects > 0) {
|
|
@@ -2344,14 +2368,14 @@ async function executePgRestore(command) {
|
|
|
2344
2368
|
}
|
|
2345
2369
|
|
|
2346
2370
|
// Agregar detalle de lo que se está procesando
|
|
2347
|
-
const relevantLine =
|
|
2371
|
+
const relevantLine = trimmed.substring(0, 100);
|
|
2348
2372
|
if (relevantLine) {
|
|
2349
2373
|
progressMsg += ` - ${relevantLine}`;
|
|
2350
2374
|
}
|
|
2351
2375
|
|
|
2352
|
-
logInfo(progressMsg); //
|
|
2376
|
+
// logInfo(progressMsg); // Ya mostramos raw stderr arriba
|
|
2353
2377
|
addCommandLog('info', progressMsg).catch(() => { });
|
|
2354
|
-
|
|
2378
|
+
lastLogTimeWeb = now;
|
|
2355
2379
|
}
|
|
2356
2380
|
}
|
|
2357
2381
|
}
|