pause() { this.paused = true; if (this.output === '-') { this.proc.stdout.pause(); return; } if (['win32', 'win64'].includes(os.platform())) { this.proc.stdin.write('c'); } else { this.proc.kill('SIGSTOP'); } }
child.on('close', (code) => { // Closing. if (code != 0) logger.error('Server exited with code ' + code + '.') else logger.state('Server exited with code 0.') child.stdin.end() if (readyToQuit) { if (!testOk) process.exit(1) else process.exit() } })
// write plot option setTimeout(function() { try { //ngspice.stdin.write('set ngbehavior=ps\n'); ngspice.stdin.write('source ' + tmp_file_path + socket.id + '-test.sp\n'); ngspice.stdin.write('wrdata ' + tmp_file_path + socket.id + '-test.data ' + label_info.map((item) => { return item.curve; }).join(' ')); ngspice.stdin.end(); } catch (e) { // do nothing console.log(e); } }, 100);
/** * @returns Promise */ stop() { get(this.stop_url, {}, () => {}); this._setup.process().stdin.pause(); this._setup.process().kill(); return Promise.resolve(); }
function cli(args, stdin = null) { const cli = path.resolve(__dirname, "..", "cli.js"); return new Promise((resolve, reject) => { let stdout = ""; let stderr = ""; const cmd = spawn("node", [cli].concat(args)); cmd.stdout.on("data", chunk => stdout += chunk); cmd.stderr.on("data", chunk => stderr += chunk); if (stdin) { cmd.stdin.end(stdin); } cmd.on("close", code => resolve({ stdout, stderr, code })); cmd.on("error", err => reject(err)); }); }
bridge.allOnce(['config', 'mixer'], function (config, mixer) { const spawn = require('child_process').spawn; var ffmpeg = spawn('ffmpeg', [ '-f', 's16le', // Input is signed 16-bit raw PCM '-ac', config.output.channels, // Input channels '-ar', config.output.samplerate, // Input sample rate '-i', '-', // Get from stdin '-c:a', 'libmp3lame', // Specify LAME MP3 encoder '-ac', config.output.channels, // Output channels '-ar', config.output.samplerate, // Output sample rate '-ab', config.mp3.bitrate + 'k', // Bitrate '-af', config.mp3.normalize ? 'dynaudnorm=f=250:g=15' : 'anull', // Use Dynamic Range Normalization? (sounds like real radio), '-bufsize', config.mp3.bitrate * 2 + 'k', // 2 seconds of buffer '-f', 'mp3', // MP3 container, clean output '-' // Output to stdout ]); mixer.pipe(ffmpeg.stdin); ffmpeg.stderr.resume(); ffmpeg.stdout.resume(); bridge.emitSticky('mp3_stream', ffmpeg.stdout); });
it('should print messages to console when using --verbose option', function (done) { this.timeout(6000); exec('./cli.js add http://localhost:9194/data', err => { if (err) { return done(err); } const child = spawn('./cli.js', ['start', '--verbose']); child.stderr.on('data', err => { throw new Error(err.toString()); }); child.stdin.end(); child.stdout.on('data', data => { assert.notEqual(data.toString().split('pathToMocks'), -1); child.kill(); done(err); }); }).stdin.end(); });
_sendObject(obj) { const json = JSON.stringify(obj); debug(`Sending to Prolog: ${json}.`); this.swipl.stdin.write(`${json}\n`); this.state.setWaiting(); }
/** * Issues a file open command to the running SQLite 3 binary. Note that the binary * automatically updates the opened file so no "save" function is provided. * * @param {String} dbFilePath The filesystem path to the default SQLite 3 database file to * open. If the file doesn't exist it will be created if possible. */ openDBFile(dbFilePath) { console.log ("SQLite3 > Opening database file: "+dbFilePath); dbFilePath = dbFilePath.split("\\").join("/"); //sqlite requires all paths to use forward slashes (even Windows) this._initData.dbFilePath = dbFilePath; var promise = new Promise((resolve, reject) => { this._sqlite3.stdin.write(".open "+this._initData.dbFilePath+"\n"); //issue ".open" command this.currentPromise = new Object(); //use a non-standard structure for this call: this.currentPromise.resolve = this.onOpenDBFile; this.currentPromise.openResolve = resolve; this.currentPromise.reject = this.onOpenDBFileFail; this.currentPromise.openReject = reject; }); return (promise); }
// Create a route that will respond to a POST request app.get('/command', function(request, response) { // Get the command from the HTTP request and send it to the Minecraft // server process var command = request.param('Body'); minecraftServerProcess.stdin.write(command+'\n'); // buffer output for a quarter of a second, then reply to HTTP request var buffer = []; var collector = function(data) { data = data.toString(); buffer.push(data.split(']: ')[1]); }; minecraftServerProcess.stdout.on('data', collector); setTimeout(function() { minecraftServerProcess.stdout.removeListener('data', collector); response.send(buffer.join('')); }, 250); });
// Quit. setTimeout (function() { logger.state('Finishing up...') child.stdin.write('/quit') }, 6500)
resume() { this.paused = false; if (this.output === '-') { this.proc.stdout.resume(); } if (['win32', 'win64'].includes(os.platform())) { this.proc.stdin.write('\n'); } else { this.proc.kill('SIGCONT'); } }