我正在永远运行我的node.js服务器,我的脚本在1-2天内被杀死,我在日志文件中收到此错误:
error: Forever detected script was killed by signal: SIGSEGV
现在我的node.js脚本中有很多函数。在每个函数的开头写一个console.log后,我最终得到了这个日志:
info: transport end (undefined)
debug: set close timeout for client CbU1mvlYaIvDWHB4ChQa
debug: cleared close timeout for client CbU1mvlYaIvDWHB4ChQa
disconnection function
debug: discarding transport
debug: clearing poll timeout
debug: client authorized
info: handshake authorized 2O3m1B3dGWFOJ4W9ChQc
error: Forever detected script was killed by signal: SIGSEGV
日志使得看起来好像连接或断开连接功能都有问题,但是由于脚本在运行2天后出现故障并且超过10000个连接/断开连接,我认为这可能不是真正的问题。 / p>
这是我的连接和断开功能。我还通过node-dbi连接到我的pgsql数据库:
var DBWrapper = require('node-dbi').DBWrapper;
var DBExpr = require('node-dbi').DBExpr;
var dbConnectionConfig = { host: 'localhost', user: 'user', password: 'pass', database: 'dbname' };
dbWrapper = new DBWrapper( "pg", dbConnectionConfig );
dbWrapper.connect();
io.sockets.on('connection', function(socket) {
console.log("socket connection");
socket.on('set username', function(userName) {
var milliseconds = (new Date).getTime();
var data = { socketid: socket.id, time: milliseconds };
dbWrapper.insert('all_sockets', data , function(err) {
});
});
socket.on('disconnect', function() {
console.log("disconnection function");
dbWrapper.remove('all_sockets', [['socketid=?', socket.id]] , function(err) {} );
});
});
段故障可能来自哪里?