在错误和退出时节点0.12 child_process.exec上混淆

时间:2016-04-21 17:16:05

标签: node.js

所以当我删除getLog.py并运行以下代码时,错误未被调用,为什么会这样?

app.get('/getLog', isAuthenticated, hasLicense, function(req, res)
{
    console.log("getting log ......");
    logger.debug("getting log ......");

    var myCmd = exec('/usr/bin/python getLog.py');
    myCmd.on(('error'), function(code) {
        logger.error("Error running getLog.py");
        console.log("Error running getLog.py");
        res.sendStatus(500);
    });
    myCmd.on(('exit'), function(code, signal) {
        console.log("Running getLog.py ok 1, code=" + signal);
        res.send(); 
    });
    myCmd.on(('close'), function(code, signal) {
        console.log("Running getLog.py ok 2, code=" + signal);
        res.send(); 
    });
    myCmd.on(('disconnect'), function(code, signal) {
        console.log("Running getLog.py ok 3, code=" + signal);
        res.send(); 
    });
});

获取日志......

[2016-04-21 13:01:17.832] [DEBUG] istar - 获取日志......

运行getLog.py ok 1,code = null

运行getLog.py ok 2,code = null

0 个答案:

没有答案