959290
node做的网站,由于一些异常,程序老是退出,怎么处理呢? 而且退出后session都没了,
node做的网站,由于一些异常,程序老是退出,怎么处理呢? 而且退出后session都没了,
关键是什么异常?发出来看看
process.on('uncaughtException',function(err){
console.log('uncaughtException-->'+err.stack+'--'+new Date().toLocaleDateString()+'-'+new Date().toLocaleTimeString());
process.exit();
});
查看一下未被捕捉的错误
var domain = require('domain');
var catchError=domain.create();
catchError.on('error', function(e) {
console.log("applicationException-->"+ e.stack+'--'+new Date().toLocaleDateString()+'-'+new Date().toLocaleTimeString());
});
异步错误捕获
用mongoStore存session吧
同上 部署用pm2,会自动重启进程 session持久化存储
pm2,session持久化