Cómo matar childprocess en nodejs?
Creó un proceso hijo usando shelljs
!/usr/bin/env node
require('/usr/local/lib/node_modules/shelljs/global');
fs = require("fs");
var child=exec("sudo mongod &",{async:true,silent:true});
function on_exit(){
console.log('Process Exit');
child.kill("SIGINT");
process.exit(0)
}
process.on('SIGINT',on_exit);
process.on('exit',on_exit);
El proceso hijo todavía se está ejecutando .. después de matar el proceso padre
39
Author: Deepak Patil, 2013-11-25
1 answers
Si puede usar el nodo integrado child_process.spawn
, puedes enviar una señal SIGINT
al proceso hijo:
var proc = require('child_process').spawn('mongod');
proc.kill('SIGINT');
Una ventaja de esto es que el proceso principal debe permanecer hasta que todos los procesos hijos hayan terminado.
55
Author: Michael Tang,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-25 10:14:45
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-25 10:14:45