fix: remove unwanted async calls
This commit is contained in:
parent
2151c4b4aa
commit
c1044232e9
3 changed files with 11 additions and 11 deletions
|
|
@ -12,19 +12,19 @@ const variables = require('./utils/variables')
|
||||||
var certificate = {}
|
var certificate = {}
|
||||||
var connectionInfo = {}
|
var connectionInfo = {}
|
||||||
|
|
||||||
async function getCert (machineIndex) {
|
const getCert = machineIndex => {
|
||||||
const key = fs.readFile(path.resolve(__dirname, 'machines', `${machineIndex}`, 'client.key'))
|
const key = fs.readFile(path.resolve(__dirname, 'machines', `${machineIndex}`, 'client.key'))
|
||||||
const cert = fs.readFile(path.resolve(__dirname, 'machines', `${machineIndex}`, 'client.pem'))
|
const cert = fs.readFile(path.resolve(__dirname, 'machines', `${machineIndex}`, 'client.pem'))
|
||||||
|
|
||||||
return Promise.all([key, cert]).then(values => {
|
return Promise.all([key, cert]).then(([key, cert]) => {
|
||||||
return { key: values[0], cert: values[1] }
|
return { key, cert }
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.err('The following error when reading the certificate: ', err)
|
console.error('The following error when reading the certificate: ', err)
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getConnectionInfo (machineIndex) {
|
const getConnectionInfo = machineIndex => {
|
||||||
return fs.readFile(path.resolve(__dirname, 'machines', `${machineIndex}`, 'connection_info.json'))
|
return fs.readFile(path.resolve(__dirname, 'machines', `${machineIndex}`, 'connection_info.json'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ let counter = 0
|
||||||
const requestTimes = []
|
const requestTimes = []
|
||||||
let latestResponseTime = 0
|
let latestResponseTime = 0
|
||||||
|
|
||||||
function request (machineIndex, pid) {
|
const request = (machineIndex, pid) => {
|
||||||
performance.mark('A')
|
performance.mark('A')
|
||||||
https.get({
|
https.get({
|
||||||
hostname: 'localhost',
|
hostname: 'localhost',
|
||||||
|
|
@ -73,7 +73,7 @@ process.on('message', async (msg) => {
|
||||||
certificate = values[0]
|
certificate = values[0]
|
||||||
connectionInfo = JSON.parse(values[1])
|
connectionInfo = JSON.parse(values[1])
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.err('The following error occurred during certificate parsing: ', err)
|
console.error('The following error occurred during certificate parsing: ', err)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (msg.hasVariance) await new Promise(resolve => setTimeout(resolve, utils.randomIntFromInterval(1, variables.POLLING_INTERVAL)))
|
if (msg.hasVariance) await new Promise(resolve => setTimeout(resolve, utils.randomIntFromInterval(1, variables.POLLING_INTERVAL)))
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ const minimist = require('minimist')
|
||||||
const cmd = require('./scripts')
|
const cmd = require('./scripts')
|
||||||
const variables = require('./utils/variables')
|
const variables = require('./utils/variables')
|
||||||
|
|
||||||
async function createMachines (numberOfMachines) {
|
function createMachines (numberOfMachines) {
|
||||||
await cmd.execCommand(
|
return cmd.execCommand(
|
||||||
`bash ./scripts/create-machines.sh ${numberOfMachines} ${variables.SERVER_CERT_PATH} ${variables.MACHINE_PATH}`
|
`bash ./scripts/create-machines.sh ${numberOfMachines} ${variables.SERVER_CERT_PATH} ${variables.MACHINE_PATH}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -20,8 +20,8 @@ async function run (args = minimist(process.argv.slice(2))) {
|
||||||
const NUMBER_OF_MACHINES = args._[0]
|
const NUMBER_OF_MACHINES = args._[0]
|
||||||
const HAS_VARIANCE = args.v || false
|
const HAS_VARIANCE = args.v || false
|
||||||
|
|
||||||
startServer()
|
|
||||||
await createMachines(NUMBER_OF_MACHINES)
|
await createMachines(NUMBER_OF_MACHINES)
|
||||||
|
startServer()
|
||||||
|
|
||||||
for (let i = 1; i <= NUMBER_OF_MACHINES; i++) {
|
for (let i = 1; i <= NUMBER_OF_MACHINES; i++) {
|
||||||
const forked = fork('child.js')
|
const forked = fork('child.js')
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ const exec = require('child_process').exec
|
||||||
* @param {String} cmd
|
* @param {String} cmd
|
||||||
* @return {Object} { stdout: String, stderr: String }
|
* @return {Object} { stdout: String, stderr: String }
|
||||||
*/
|
*/
|
||||||
async function execCommand (cmd) {
|
function execCommand (cmd) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
const proc = exec(cmd, (err, stdout, stderr) => {
|
const proc = exec(cmd, (err, stdout, stderr) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue