mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-09 18:59:36 +00:00
fix(downloads): allow aria2 graceful shutdown delay
This commit is contained in:
@@ -153,7 +153,7 @@ function childExited(child) {
|
||||
return child.exitCode !== null || child.signalCode !== null;
|
||||
}
|
||||
|
||||
async function waitForChildExit(child, timeoutMs = 3000) {
|
||||
async function waitForChildExit(child, timeoutMs = 8000) {
|
||||
if (childExited(child)) return true;
|
||||
return new Promise(resolve => {
|
||||
let settled = false;
|
||||
@@ -216,7 +216,6 @@ const payload = Buffer.alloc(4 * 1024 * 1024, 0x5a);
|
||||
const checksum = crypto.createHash('sha256').update(payload).digest('hex');
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'firelink-aria2-transfers-'));
|
||||
const serverStatPath = path.join(tempRoot, 'server-stat.txt');
|
||||
const serverStatOutputPath = path.join(tempRoot, 'server-stat.next');
|
||||
fs.writeFileSync(serverStatPath, '', { mode: 0o600 });
|
||||
let finalRequests = 0;
|
||||
let finalCredentials = [];
|
||||
@@ -322,7 +321,7 @@ const child = spawn(binaryPath, [
|
||||
'--console-log-level=error',
|
||||
'--quiet=true',
|
||||
`--server-stat-if=${serverStatPath}`,
|
||||
`--server-stat-of=${serverStatOutputPath}`,
|
||||
`--server-stat-of=${serverStatPath}`,
|
||||
], { env: environment, stdio: ['ignore', 'ignore', 'pipe'] });
|
||||
let stderr = '';
|
||||
child.stderr.on('data', chunk => { stderr += chunk.toString(); });
|
||||
@@ -463,7 +462,7 @@ try {
|
||||
try {
|
||||
await stop(child, rpcPort, secret);
|
||||
if (smokePassed) {
|
||||
const stat = fs.readFileSync(serverStatOutputPath, 'utf8');
|
||||
const stat = fs.readFileSync(serverStatPath, 'utf8');
|
||||
if (!stat.includes('host=127.0.0.1')) {
|
||||
throw new Error(`Aria2 did not persist adaptive mirror statistics: ${JSON.stringify(stat)}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user