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 connectionInfo = {}
|
||||
|
||||
async function getCert (machineIndex) {
|
||||
const getCert = machineIndex => {
|
||||
const key = fs.readFile(path.resolve(__dirname, 'machines', `${machineIndex}`, 'client.key'))
|
||||
const cert = fs.readFile(path.resolve(__dirname, 'machines', `${machineIndex}`, 'client.pem'))
|
||||
|
||||
return Promise.all([key, cert]).then(values => {
|
||||
return { key: values[0], cert: values[1] }
|
||||
return Promise.all([key, cert]).then(([key, cert]) => {
|
||||
return { key, cert }
|
||||
}).catch(err => {
|
||||
console.err('The following error when reading the certificate: ', err)
|
||||
console.error('The following error when reading the certificate: ', err)
|
||||
return null
|
||||
})
|
||||
}
|
||||
|
||||
async function getConnectionInfo (machineIndex) {
|
||||
const getConnectionInfo = machineIndex => {
|
||||
return fs.readFile(path.resolve(__dirname, 'machines', `${machineIndex}`, 'connection_info.json'))
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ let counter = 0
|
|||
const requestTimes = []
|
||||
let latestResponseTime = 0
|
||||
|
||||
function request (machineIndex, pid) {
|
||||
const request = (machineIndex, pid) => {
|
||||
performance.mark('A')
|
||||
https.get({
|
||||
hostname: 'localhost',
|
||||
|
|
@ -73,7 +73,7 @@ process.on('message', async (msg) => {
|
|||
certificate = values[0]
|
||||
connectionInfo = JSON.parse(values[1])
|
||||
}).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)))
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ const minimist = require('minimist')
|
|||
const cmd = require('./scripts')
|
||||
const variables = require('./utils/variables')
|
||||
|
||||
async function createMachines (numberOfMachines) {
|
||||
await cmd.execCommand(
|
||||
function createMachines (numberOfMachines) {
|
||||
return cmd.execCommand(
|
||||
`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 HAS_VARIANCE = args.v || false
|
||||
|
||||
startServer()
|
||||
await createMachines(NUMBER_OF_MACHINES)
|
||||
startServer()
|
||||
|
||||
for (let i = 1; i <= NUMBER_OF_MACHINES; i++) {
|
||||
const forked = fork('child.js')
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const exec = require('child_process').exec
|
|||
* @param {String} cmd
|
||||
* @return {Object} { stdout: String, stderr: String }
|
||||
*/
|
||||
async function execCommand (cmd) {
|
||||
function execCommand (cmd) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
const proc = exec(cmd, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue