mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
reduce Mongo db connection retry warnings
only report on first attempt to close issue 1052 on main project
This commit is contained in:
parent
5c1edc641a
commit
7a39c6f70b
@ -35,7 +35,6 @@ module.exports = function(RED) {
|
|||||||
return selector;
|
return selector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function MongoOutNode(n) {
|
function MongoOutNode(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.collection = n.collection;
|
this.collection = n.collection;
|
||||||
@ -47,16 +46,19 @@ module.exports = function(RED) {
|
|||||||
this.mongoConfig = RED.nodes.getNode(this.mongodb);
|
this.mongoConfig = RED.nodes.getNode(this.mongodb);
|
||||||
this.status({fill:"grey",shape:"ring",text:RED._("mongodbstatus.connecting")});
|
this.status({fill:"grey",shape:"ring",text:RED._("mongodbstatus.connecting")});
|
||||||
var node = this;
|
var node = this;
|
||||||
|
var noerror = true;
|
||||||
|
|
||||||
var connectToDB = function() {
|
var connectToDB = function() {
|
||||||
MongoClient.connect(node.mongoConfig.url, function(err, db) {
|
MongoClient.connect(node.mongoConfig.url, function(err, db) {
|
||||||
if (err) {
|
if (err) {
|
||||||
node.status({fill:"red",shape:"ring",text:RED._("mongodb.status.error")});
|
node.status({fill:"red",shape:"ring",text:RED._("mongodb.status.error")});
|
||||||
node.error(err);
|
if (noerror) { node.error(err); }
|
||||||
|
noerror = false;
|
||||||
node.tout = setTimeout(connectToDB, 10000);
|
node.tout = setTimeout(connectToDB, 10000);
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")});
|
node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")});
|
||||||
node.clientDb = db;
|
node.clientDb = db;
|
||||||
|
noerror = true;
|
||||||
var coll;
|
var coll;
|
||||||
if (node.collection) {
|
if (node.collection) {
|
||||||
coll = db.collection(node.collection);
|
coll = db.collection(node.collection);
|
||||||
@ -162,16 +164,19 @@ module.exports = function(RED) {
|
|||||||
this.mongoConfig = RED.nodes.getNode(this.mongodb);
|
this.mongoConfig = RED.nodes.getNode(this.mongodb);
|
||||||
this.status({fill:"grey",shape:"ring",text:RED._("mongodb.status.connecting")});
|
this.status({fill:"grey",shape:"ring",text:RED._("mongodb.status.connecting")});
|
||||||
var node = this;
|
var node = this;
|
||||||
|
var noerror = true;
|
||||||
|
|
||||||
var connectToDB = function() {
|
var connectToDB = function() {
|
||||||
MongoClient.connect(node.mongoConfig.url, function(err,db) {
|
MongoClient.connect(node.mongoConfig.url, function(err,db) {
|
||||||
if (err) {
|
if (err) {
|
||||||
node.status({fill:"red",shape:"ring",text:RED._("mongodb.status.error")});
|
node.status({fill:"red",shape:"ring",text:RED._("mongodb.status.error")});
|
||||||
node.error(err);
|
if (noerror) { node.error(err); }
|
||||||
|
noerror = false;
|
||||||
node.tout = setTimeout(connectToDB, 10000);
|
node.tout = setTimeout(connectToDB, 10000);
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")});
|
node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")});
|
||||||
node.clientDb = db;
|
node.clientDb = db;
|
||||||
|
noerror = true;
|
||||||
var coll;
|
var coll;
|
||||||
if (node.collection) {
|
if (node.collection) {
|
||||||
coll = db.collection(node.collection);
|
coll = db.collection(node.collection);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-mongodb",
|
"name" : "node-red-node-mongodb",
|
||||||
"version" : "0.0.10",
|
"version" : "0.0.11",
|
||||||
"description" : "Node-RED nodes to talk to an Mongo database",
|
"description" : "Node-RED nodes to talk to an Mongo database",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"mongodb" : "^2.2.11"
|
"mongodb" : "^2.2.11"
|
||||||
|
Loading…
Reference in New Issue
Block a user