Javascript nodejs永远监视不终止fork进程

Javascript nodejs永远监视不终止fork进程,javascript,node.js,forever,Javascript,Node.js,Forever,我正在nodejs中设置一个应用程序,它由一个主进程(api.js)和另一个主进程(使用.fork())组成 此外,我还拥有永久监视器,以确保在发生任何事件时一切正常运行 当主应用程序中发生了一些事情时,问题就来了,永远是行为,重新生成它。但它并没有杀死次级分叉线程 因此,在模拟了一些错误之后,ps aux中的进程堆栈在没有任何控制的情况下变得越来越大 我正在使用killTree参数,没有任何运气 任何帮助???永久监视器以分离的子进程状态启动子进程,因此这是预期的行为。您的自定义永久监视器脚本

我正在nodejs中设置一个应用程序,它由一个主进程(api.js)和另一个主进程(使用.fork())组成

此外,我还拥有永久监视器,以确保在发生任何事件时一切正常运行

当主应用程序中发生了一些事情时,问题就来了,永远是行为,重新生成它。但它并没有杀死次级分叉线程

因此,在模拟了一些错误之后,ps aux中的进程堆栈在没有任何控制的情况下变得越来越大

我正在使用killTree参数,没有任何运气


任何帮助???

永久监视器以分离的子进程状态启动子进程,因此这是预期的行为。您的自定义永久监视器脚本必须处理来自您正在使用的任何对象的信号,并适当地操纵子进程

请参阅本文:

var forever = require('forever-monitor');
process.stdin.resume();

var child = new(forever.Monitor)('Index.js', {
    max: 5,
    silent: false,
    minUptime: 2000,
    spinSleepTime: 5000
});

child.on('start', function() {
    console.log('Forever started for first time.');
});

child.on('exit', function() {
    console.error('Index.js file has exited after '+child.max+' restarts');
});

//Exit handler.
function exitHandler(options, err) {
    try{
        //Killing node process manually that is running "Index.js" file.
        process.kill(child.childData.pid);
        console.log("Child process killed succesfully!!");
        console.log("Forever exit!!");
    }
    catch(err){
        console.log("Child process already stopped!!");
        console.log("Forever exit!!");
    }

    //Killing forever process.
    process.exit();
}

//Handling user exit events like Ctrl+C.
process.on('SIGINT', exitHandler.bind(null, {exit: true}));    

child.start();