处理节点uncaughtException并关闭连接

时间:2014-07-23 22:05:54

标签: node.js

为了不崩溃服务器,我们在main.js中捕获任何未捕获的异常。但是,请求不会终止。有没有办法终止活动请求?

//keep server from crashing by catching all exceptions not caught before
process.on('uncaughtException', function(err) {
    console.log(err);
    //kill request that caused the error
});

//launch server
https.createServer(options, app).listen(appSettings.ports.https, function(){
    console.log('Express https server listening on port %d in %s mode',appSettings.ports.https, app.settings.env);
});

0 个答案:

没有答案