mirror of https://github.com/calzoneman/sync.git
Solve some database reconnection issues
This commit is contained in:
parent
98b6273dc4
commit
8776ae15fc
16
database.js
16
database.js
|
@ -41,12 +41,22 @@ function getConnection() {
|
||||||
Logger.errlog.log("DB connection failed");
|
Logger.errlog.log("DB connection failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(CONFIG["debug"]) {
|
|
||||||
db._querySync = db.querySync;
|
db._querySync = db.querySync;
|
||||||
db.querySync = function(q) {
|
db.querySync = function(q) {
|
||||||
Logger.syslog.log("DEBUG: " + q);
|
if(!this.connectedSync()) {
|
||||||
return this._querySync(q);
|
db = false;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
var res = this._querySync(q);
|
||||||
|
if(!res) {
|
||||||
|
try {
|
||||||
|
db.closeSync();
|
||||||
|
} catch(e) {
|
||||||
|
// already disconnected
|
||||||
|
}
|
||||||
|
db = false;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue