我正在運行我的node.js服務器,並且我的腳本在1-2天內死亡,並且在日誌文件中出現此錯誤:node.js socket.io腳本在1-2天后被SIGSEGV殺死
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
日誌使它看起來好像無論是連接或斷開功能有問題,而是因爲劇本seg運行2天后的故障以及超過10000次連接/斷開連接,我認爲這可能不是真正的問題。
這是我的連接和斷開功能。我也通過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) {});
});
});
哪裏可以發生段故障?
你使用任何編譯插件?如果你是'find node_modules/-name \ *。node''應該顯示結果。您是否在主入口腳本的目錄中獲得了coredump(例如node.core)? – mscdex
find命令給我這個: node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build/Release/obj.target/bufferutil.node node_modules/socket.io/node_modules/socket.io -client/node_modules/ws/build/Release/obj.target/validation.node node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build/Release/bufferutil.node node_modules/socket.io /node_modules/socket.io-client/node_modules/ws/build/Release/validation.node node_modules/pg/build/Release/obj.target/binding.node node_modules/pg/build/Release/binding.node i沒有得到一個.core文件的腳本 – user3455531
的目錄中的任何幫助?我在2天后得到了另一個錯誤 – user3455531