ajusta tratamento de saída de streams no DockerService para evitar travamentos e garantir a resolução de promessas
This commit is contained in:
parent
007a87a536
commit
ee7bec2d66
|
|
@ -489,13 +489,15 @@ class BackupService {
|
||||||
maxOkExitCode: 1,
|
maxOkExitCode: 1,
|
||||||
onOutput: (line, stream) => {
|
onOutput: (line, stream) => {
|
||||||
const normalizedLine = String(line || '').trim();
|
const normalizedLine = String(line || '').trim();
|
||||||
if (!normalizedLine || stream !== 'stderr' || normalizedLine.startsWith('__DBKP_TAR_BEGIN__')) {
|
if (!normalizedLine || normalizedLine.startsWith('__DBKP_TAR_BEGIN__')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!normalizedLine.startsWith('tar:')) {
|
// No helper (tar escreve em arquivo): lista de arquivos vai para stdout;
|
||||||
|
// avisos do tar vão para stderr.
|
||||||
|
if (stream === 'stdout' && !normalizedLine.startsWith('tar:')) {
|
||||||
fileCurrent += 1;
|
fileCurrent += 1;
|
||||||
updateFileProgress(normalizedLine);
|
updateFileProgress(normalizedLine);
|
||||||
} else {
|
} else if (stream === 'stderr') {
|
||||||
pushLog(`Aviso do tar: ${normalizedLine}`, 'gerando-tar');
|
pushLog(`Aviso do tar: ${normalizedLine}`, 'gerando-tar');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -654,6 +654,15 @@ class DockerService {
|
||||||
|
|
||||||
await container.start();
|
await container.start();
|
||||||
const result = await container.wait();
|
const result = await container.wait();
|
||||||
|
|
||||||
|
// Destruir o attachStream para que os PassThrough streams emitam 'end'
|
||||||
|
// e as outputPromises possam resolver. Sem isso o runHelper trava indefinidamente.
|
||||||
|
if (attachStream && typeof attachStream.destroy === 'function') {
|
||||||
|
attachStream.destroy();
|
||||||
|
}
|
||||||
|
stdoutStream.end();
|
||||||
|
stderrStream.end();
|
||||||
|
|
||||||
await Promise.all(outputPromises);
|
await Promise.all(outputPromises);
|
||||||
|
|
||||||
output = output.trim();
|
output = output.trim();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue