exports.procCtrl = function(args, opt, callback) { console.log(args); switch(args[0]) { case 'start':{ var exec= require('child_process').exec; var cmd = exec(args[2], args[3]); callback(null, {'ret':'OK'}); } break; case 'stop':{ psnode.kill(args[2], function(err){ if(err) callback(null, {'error':err}); else callback(null, {'ret':'OK'}); }); } break; case 'restart':{ psnode.kill(args[2], function(err){ if(err) callback(null, {'error':err}); else{ var exec= require('child_process').exec; var cmd = exec(args[2], args[3]); callback(null, {'ret':'OK'}); } }); } break; } }
var killer = setTimeout(function() { console.log('Killing phantomas because the test on ' + task.url + ' was launched ' + 5*options.timeout + ' seconds ago'); if (phantomasPid) { ps.kill(phantomasPid, function(err) { if (err) { debug('Could not kill Phantomas process %s', phantomasPid); // Suicide process.exit(1); // If in server mode, forever will restart the server } debug('Phantomas process %s was correctly killed', phantomasPid); // Then mark the test as failed // Error 1003 = Phantomas not answering deferred.reject(1003); isKilled = true; }); } else { // Suicide process.exit(1); } }, 5*options.timeout*1000);
ps.lookup({'pid': pid}, function(err, resultList) { if (err) { callback(err); } var rogueProcess = resultList[0]; // attempt to kill the pid wether it exists or not. Ignore errors from kill command fs.unlinkSync(path.join(dataDir, pidFile)); ps.kill(pid, function() { logger.debug('killed rogue process', pid); callback(null); }); });
resultList.forEach((process) => { if (process) { ps.kill(process.pid, (err) => { if (err) { throw err } else { console.log('Process %s has been killed!', process.pid) } }) } })
videoRoute.post('/stop', function(req, res){ //salta error porque nombre no es PID ?¿?¿?¿? PERO FUNCIONA ps.kill('gst-rtsp-server-win32_64.exe', function( err ) { if (err) { throw new Error( err ); } else { res.send(200, "Okey"); console.log( 'Process gstreamer has been killed!'); } }); });
var killer = setTimeout(function() { debug('Killing the app because the test on %s was launched %d seconds ago', task.url, 5*options.timeout); // If in server mode, forever will restart the server // Kill the Phantomas process first if (phantomasPid) { ps.kill(phantomasPid, function(err) { if (err) { debug('Could not kill Phantomas process %s', phantomasPid); } else { debug('Phantomas process %s was correctly killed', phantomasPid); } // Then suicide. process.exit(1); }); } }, 5*options.timeout*1000);
return new Promise(function (resolve, reject) { ps.kill(p.pid, resolve); });
return new Promise((resolve, reject) => { ps.kill(pid, (err) => { if (err) return reject(err) return resolve(pid) }) })
return new Promise((resolve, reject) => { ps.kill(p.pid, resolve); });