去掉重连部分代码,让其重启

This commit is contained in:
luchenqun 2017-04-19 11:23:11 +08:00
parent 331a76c0e9
commit 0dbe1e0119
1 changed files with 2 additions and 26 deletions

View File

@ -8,32 +8,8 @@ var dbConfig = {
useConnectionPooling: true,
port: 3306
};
var client = {}
var disconnect = 0;
function handleDisconnect() {
console.error("handleDisconnect, disconnect = ", disconnect++);
client = mysql.createConnection(dbConfig);
client.connect(function(err) {
if (err) {
console.log('error when connecting to db:', err);
setTimeout(handleDisconnect, 2000);
}
});
client.on('error', function(err) {
console.log('db error', err);
if (err.code === 'PROTOCOL_CONNECTION_LOST') {
handleDisconnect();
} else {
throw err;
}
});
}
handleDisconnect();
var client = mysql.createConnection(dbConfig);
Date.prototype.format = function(fmt) { //author: meizz
var o = {
@ -66,7 +42,7 @@ setInterval(function () {
throw new Error("数据查询出问题了直接挂掉程序让forever重启应用错误信息" + JSON.stringify(err));
}
});
}, 10000);
}, 60000);
db.getBookmarkbyUrl = function(user_id, url) {