From fe1a96d67d27ea36b0c9cdf1a671761a09404b7e Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sun, 27 Nov 2016 19:21:57 +0000 Subject: [PATCH] tidy up mysql some more remove listeners on close and update status on partial deploy --- storage/mysql/68-mysql.js | 11 ++++++++--- storage/mysql/package.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/storage/mysql/68-mysql.js b/storage/mysql/68-mysql.js index b8fc46eb..c2e85422 100644 --- a/storage/mysql/68-mysql.js +++ b/storage/mysql/68-mysql.js @@ -56,9 +56,9 @@ module.exports = function(RED) { } this.connect = function() { - if (!this.connected && !this.connecting) { - doConnect(); - } + if (!this.connected && !this.connecting) { doConnect(); } + if (this.connected) { node.emit("state","connected"); } + else { node.emit("state","connecting"); } } this.on('close', function (done) { @@ -127,6 +127,11 @@ module.exports = function(RED) { node.status({fill:"red",shape:"ring",text:"not yet connected"}); } }); + + node.on('close', function () { + node.mydbConfig.removeAllListeners(); + node.status({}); + }); } else { this.error("MySQL database not configured"); diff --git a/storage/mysql/package.json b/storage/mysql/package.json index 1dcc88df..75916816 100644 --- a/storage/mysql/package.json +++ b/storage/mysql/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-mysql", - "version" : "0.0.12", + "version" : "0.0.13", "description" : "A Node-RED node to read and write to a MySQL database", "dependencies" : { "mysql" : "^2.12.0"