feat: multiprocessing and some diagnostics
This commit is contained in:
parent
86e437a23a
commit
c75319d166
4 changed files with 40 additions and 9 deletions
|
|
@ -1,20 +1,25 @@
|
|||
|
||||
const { fork } = require('child_process')
|
||||
const minimist = require('minimist')
|
||||
|
||||
const cmd = require('./scripts')
|
||||
const variables = require('./utils/variables')
|
||||
|
||||
async function createMachines () {
|
||||
async function createMachines (numberOfMachines) {
|
||||
await cmd.execCommand(
|
||||
`bash ./scripts/create-machines.sh ${variables.NUMBER_OF_MACHINES} ${variables.SERVER_CERT_PATH} ${variables.MACHINE_PATH}`
|
||||
`bash ./scripts/create-machines.sh ${numberOfMachines} ${variables.SERVER_CERT_PATH} ${variables.MACHINE_PATH}`
|
||||
)
|
||||
}
|
||||
|
||||
async function run () {
|
||||
await createMachines()
|
||||
async function run (args = minimist(process.argv.slice(2))) {
|
||||
const NUMBER_OF_MACHINES = args._[0]
|
||||
const HAS_VARIANCE = args.v || false
|
||||
|
||||
for (let i = 1; i <= variables.NUMBER_OF_MACHINES; i++) {
|
||||
await createMachines(NUMBER_OF_MACHINES)
|
||||
|
||||
for (let i = 1; i <= NUMBER_OF_MACHINES; i++) {
|
||||
const forked = fork('child.js')
|
||||
forked.send({ machineIndex: i })
|
||||
forked.send({ machineIndex: i, hasVariance: HAS_VARIANCE })
|
||||
forked.on('message', msg => {
|
||||
console.log(`Message from child ${i}: ${msg}`)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue