mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
mysql faster/tidier closing of pool if never connected.
This commit is contained in:
parent
3ffd3f9fad
commit
0b3b918528
@ -65,19 +65,26 @@ module.exports = function(RED) {
|
||||
});
|
||||
}
|
||||
|
||||
this.connect = function() {
|
||||
if (!this.connected && !this.connecting) {
|
||||
node.connect = function() {
|
||||
if (!node.connected && !node.connecting) {
|
||||
doConnect();
|
||||
}
|
||||
}
|
||||
|
||||
this.on('close', function(done) {
|
||||
if (this.tick) { clearTimeout(this.tick); }
|
||||
if (this.check) { clearInterval(this.check); }
|
||||
node.connected = false;
|
||||
node.on('close', function(done) {
|
||||
if (node.tick) { clearTimeout(node.tick); }
|
||||
if (node.check) { clearInterval(node.check); }
|
||||
// node.connection.release();
|
||||
node.emit("state"," ");
|
||||
node.pool.end(function(err) { done(); });
|
||||
if (node.connected) {
|
||||
node.connected = false;
|
||||
node.pool.end(function(err) { done(); });
|
||||
}
|
||||
else {
|
||||
delete node.pool;
|
||||
done();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("MySQLdatabase",MySQLNode, {
|
||||
@ -173,7 +180,7 @@ module.exports = function(RED) {
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.error(RED._("mysql.errors.notconfigured"));
|
||||
node.error(RED._("mysql.errors.notconfigured"));
|
||||
}
|
||||
}
|
||||
RED.nodes.registerType("mysql",MysqlDBNodeIn);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-red-node-mysql",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "A Node-RED node to read and write to a MySQL database",
|
||||
"dependencies": {
|
||||
"mysql2": "^2.3.3"
|
||||
|
Loading…
Reference in New Issue
Block a user