exec(command, (error, stdout) => { if (error) { if (error.signal == 'SIGTERM') { resolve('Process was killed'); } else { reject(error); } } else { resolve(stdout.trim()); } });
exec(command, { maxBuffer: 1024 * 1024 }, (error, stdout) => { if (error) { // Special case for robocopy, which will return non-zero error codes // when sucessful. Doc is very imprecise but <= 7 seems more or less // fine and >= 8 seems more errorish. https://ss64.com/nt/robocopy-exit.html if (command.indexOf('robocopy') === 0 && error.code <= 7) { resolve(stdout.trim()); return; } if (error.signal == 'SIGTERM') { resolve('Process was killed'); } else { const newError = new Error(`Code: ${error.code}: ${error.message}: ${stdout.trim()}`); reject(newError); } } else { resolve(stdout.trim()); } });
function addPackages() { let cmd = appendVersionsToCommand(`yarn add --dev `); child_process.exec(cmd.trim(), async (err) => { if (err) process.exit(err.code); console.log(`Done installing all versions...`); console.log("Starting benchmarks..."); await setCPUScaling(false); await runBenchmark(); await setCPUScaling(true); removePackages(); }); }
function npmInstall(dir, callback) { exec('npm install', {cwd: dir}, function (err, stderr) { if (err) { err.message += stderr; callback(err); return; } callback(); }); }
it('returns 503 once signal received', (done) => { let responseAssertionsComplete = false // We're only truly finished when the response has been analyzed and the forked http process has exited, // freeing up port 8000 for future tests execFile('node', ['lib/standalone-tests/terminus.onsignal.fail.js'], (error) => { expect(error.signal).to.eql('SIGINT') expect(responseAssertionsComplete).to.eql(true) done() }) // let the process start up setTimeout(() => { fetch('http://localhost:8000/health') .then(res => { expect(res.status).to.eql(503) responseAssertionsComplete = true }) }, 300) })
let child = exec(cmd1, function (err, stdout, stderr) { if (err) { logger.error('command %s execute with error: %j', cmd1, err.stack); invokeCallback(cb, 'error'); } else if (stdout.trim() !== '0') { exec(cmd2, function (err, stdout, stderr) { if (err) { logger.error('command %s execute with error: %j', cmd2, err.stack); invokeCallback(cb, 'error'); } else if (stdout.trim() !== '0') {
it('calls onSendFailureDuringShutdown when sending 503 during shutdown', (done) => { let responseAssertionsComplete = false // We're only truly finished when the response has been analyzed and the forked http process has exited, // freeing up port 8000 for future tests execFile('node', ['lib/standalone-tests/terminus.onsendfailureduringshutdown.js'], (error, stdout) => { expect(error.signal).to.eql('SIGTERM') expect(stdout).to.eql('onSendFailureDuringShutdown\n') expect(responseAssertionsComplete).to.eql(true) done() }) // let the process start up setTimeout(() => { fetch('http://localhost:8000/health') .then(res => { expect(res.status).to.eql(503) responseAssertionsComplete = true }) }, 300) })
cp.execFile(cmd, arg, (err, stdout) => { if(err) { console.error(err.message); process.exit(1); } console.log(stdout); });
test('return error code 1 if data passed in', function (t) { const cmd = 'minicat ' + catfile + ' | node ' + binfile exec(cmd, function (err, stdout, stderr) { t.ok(stdout.length > 0, 'stdout is correct') t.equals(err.code, 1, 'correctly exits with code 1') t.end() }) })
exec(executeCommand, function(err, stdout, stderr) { if (!err) { console.log("Test cases runned successfully...."); self.sendMail(); } else { console.error("error: ", err.message || err) } });
exec(command, function (err, stdout, stderr) { if (err) { reject(new Error(err.message + "\n" + (stdout || stderr))); } else { resolve(stdout); } });
child_process.exec(exe, function (err, stdout, stderr){ if (err) { console.log("child processes failed with error code: " + err.code); } else { pushReply(message, "The bot has now sent **" + text + "** an invite."); } });
it('does NOT call onSendFailureDuringShutdown when sending 503 during failed healthcheck', (done) => { let responseAssertionsComplete = false // We're only truly finished when the response has been analyzed and the forked http process has exited, // freeing up port 8000 for future tests execFile('node', ['lib/standalone-tests/terminus.onsendfailureduringshutdown.failed-health.js'], (error, stdout) => { expect(error.signal).to.eql('SIGTERM') // Here, we expect NOT to see "onSendFailureDuringShutdown" expect(stdout).to.eql('') expect(responseAssertionsComplete).to.eql(true) done() }) // let the process start up setTimeout(() => { fetch('http://localhost:8000/health') .then(res => { expect(res.status).to.eql(503) responseAssertionsComplete = true }) }, 300) })
function npmInstall(dir, callback) { exec('npm install', {cwd: dir}, function (err, stderr) { if (err) { err.message += stderr; callback(err); return; } callback(); }); }