Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```(async() => {
- if (cluster.isMaster) {
- console.log(`Master ${process.pid} is running`);
- const queue = fileUuids.splice(0, numCPUs);
- for (let i = 0; i < queue.length; i++) {
- console.log(`Fork process with uuid: ${queue[i]}`);
- cluster.fork({file_uuid: queue[i]});
- }
- cluster.on('exit', (worker, code) => {
- console.log(`=== Worker ${worker.process.pid} has finished task with code ${code}`);
- if (fileUuids.length) {
- const uuid = fileUuids.splice(0, 1);
- cluster.fork({file_uuid: uuid});
- }
- });
- } else {
- (async() => {
- try {
- await parseXlsx(process.env.file_uuid);
- } catch (e) {
- console.error(e);
- } finally {
- process.exit(0);
- }
- })();
- }
- })();```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement