Skip to content

Commit

Permalink
improved cross platform kill
Browse files Browse the repository at this point in the history
  • Loading branch information
inlife committed Sep 3, 2024
1 parent e7be6f6 commit 90b1d1d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/nexrender-core/src/tasks/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ const seconds = (string) => string.split(':')
.map((e, i) => (i < 3) ? +e * Math.pow(60, 2 - i) : +e * 10e-6)
.reduce((acc, val) => acc + val);

const crossPlatformKill = (instance) => {
if (process.platform === 'win32') {
// kill the aerender process and all its children
spawn('taskkill', ['/pid', instance.pid, '/f', '/t']);
} else {
instance.kill('SIGINT');
}
}

/**
* This task creates rendering process
*/
Expand Down Expand Up @@ -249,7 +258,7 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
clearTimeout(timeoutID);
settings.trackSync('Job Render Failed', { job_id: job.uid, error: 'aerender_no_update' });
reject(new Error(`No update from aerender for ${settings.maxUpdateTimeout} seconds`));
instance.kill('SIGINT');
crossPlatformKill(instance)
}
}, 5000)

Expand All @@ -261,7 +270,7 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
clearTimeout(timeoutID);
settings.trackSync('Job Render Failed', { job_id: job.uid, error: 'aerender_timeout' });
reject(new Error(`Maximum rendering time exceeded`));
instance.kill('SIGINT');
crossPlatformKill(instance)
},
timeout
);
Expand Down

0 comments on commit 90b1d1d

Please sign in to comment.