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() {
|
node.connect = function() {
|
||||||
if (!this.connected && !this.connecting) {
|
if (!node.connected && !node.connecting) {
|
||||||
doConnect();
|
doConnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.on('close', function(done) {
|
node.on('close', function(done) {
|
||||||
if (this.tick) { clearTimeout(this.tick); }
|
if (node.tick) { clearTimeout(node.tick); }
|
||||||
if (this.check) { clearInterval(this.check); }
|
if (node.check) { clearInterval(node.check); }
|
||||||
node.connected = false;
|
|
||||||
// node.connection.release();
|
// node.connection.release();
|
||||||
node.emit("state"," ");
|
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, {
|
RED.nodes.registerType("MySQLdatabase",MySQLNode, {
|
||||||
@ -173,7 +180,7 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.error(RED._("mysql.errors.notconfigured"));
|
node.error(RED._("mysql.errors.notconfigured"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("mysql",MysqlDBNodeIn);
|
RED.nodes.registerType("mysql",MysqlDBNodeIn);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-node-mysql",
|
"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",
|
"description": "A Node-RED node to read and write to a MySQL database",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"mysql2": "^2.3.3"
|
"mysql2": "^2.3.3"
|
||||||
|
Loading…
Reference in New Issue
Block a user