Update multi.js

This commit is contained in:
Penelope Gomez / Pogmommy 2023-02-07 22:23:57 -07:00 committed by GitHub
parent 68fc212d4b
commit f6cb96283b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,21 @@
const args = process.argv; const childProcess = require('child_process')
const defArgs = ["node","path","name","tweetCount","0","write","printHeader"] const path = require('path');
for (var i = 0; i < 2; i++) {args.shift();} async function fork(scriptPath, args = []) {
const config = require('fs').readFileSync("./usernameslist.txt").toString().split(/[\r\n]+/); return new Promise((resolve, reject) => {
for (let name of config) { let process = childProcess.fork(scriptPath, args, {
cwd: path.dirname(scriptPath)
});
process.on('exit', code => resolve(code));
process.on('error', err => reject(err));
});
}
(async function(){
const args = process.argv;
const defArgs = ["node","path","name","tweetCount","0","write","fromLoop"]
for (var i = 0; i < 2; i++) {args.shift();}
const config = require('fs').readFileSync("./usernameslist.txt").toString().split(/[\r\n]+/);
for (let name of config) {
var pArgs = [...args]; var pArgs = [...args];
pArgs.splice(0, 0, name); pArgs.splice(0, 0, name);
for (var i = 3; i < 7; i++) { for (var i = 3; i < 7; i++) {
@ -11,5 +24,6 @@ for (let name of config) {
} }
} }
console.log("pArgs: " + pArgs); console.log("pArgs: " + pArgs);
require('child_process').fork('./TwitToMast.js',pArgs); await fork('./TwitToMast.js', pArgs);
} }
}());