From 0dbe1e01193900bca00ddb7c8b6b2ebb2440dbe7 Mon Sep 17 00:00:00 2001 From: luchenqun Date: Wed, 19 Apr 2017 11:23:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=87=8D=E8=BF=9E=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81=EF=BC=8C=E8=AE=A9=E5=85=B6=E9=87=8D?= =?UTF-8?q?=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/db.js | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/database/db.js b/database/db.js index 0074530..2544664 100644 --- a/database/db.js +++ b/database/db.js @@ -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) {