|
|
@ -419,41 +419,36 @@ function onCollection(err, collection) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var mongourl = "mongodb://playgrounduser:efvvnuioervefSDFSGYGHRDFVsdfergvssppiiedifhwincvinviw_dbfjbsifbsdkjfswuunscfudfgbbfvibqefwrvnine@ondemand_playground_mongo1:27017,ondemand_playground_mongo2:27017,ondemand_playground_mongo3:27017,ondemand_playground_mongo4:27017,ondemand_playground_mongo5:27017,ondemand_playground_mongo6:27017,ondemand_playground_mongo7:27017/fluent?replicaSet=rs1" |
|
|
|
const OPTS = { |
|
|
|
useNewUrlParser: true, |
|
|
|
useUnifiedTopology: true |
|
|
|
}; |
|
|
|
//var mongolab_uri = "mongodb://<dbUser>:<dbPassword>@<host1>:<port1>,<host2>:<port2>/<dbName>?replicaSet=<replicaSetName>";
|
|
|
|
var mongooptions = { |
|
|
|
var mongourl = "mongodb://playgrounduser:efvvnuioervefSDFSGYGHRDFVsdfergvssppiiedifhwincvinviw_dbfjbsifbsdkjfswuunscfudfgbbfvibqefwrvnine@ondemand_playground_mongo1:27017,ondemand_playground_mongo2:27017,ondemand_playground_mongo3:27017,ondemand_playground_mongo4:27017,ondemand_playground_mongo5:27017,ondemand_playground_mongo6:27017,ondemand_playground_mongo7:27017/fluent?replicaSet=rs1" |
|
|
|
const OPTS = { |
|
|
|
useNewUrlParser: true, |
|
|
|
useUnifiedTopology: true |
|
|
|
}; |
|
|
|
//var mongolab_uri = "mongodb://<dbUser>:<dbPassword>@<host1>:<port1>,<host2>:<port2>/<dbName>?replicaSet=<replicaSetName>";
|
|
|
|
var mongooptions = { |
|
|
|
autoReconnect: true, |
|
|
|
keepAlive: 1, |
|
|
|
connectTimeoutMS: 30000, |
|
|
|
socketTimeoutMS: 0 |
|
|
|
} |
|
|
|
MongoClient.connect(mongourl, OPTS, function(err, client){ |
|
|
|
} |
|
|
|
MongoClient.connect(mongourl, OPTS, function(err, client){ |
|
|
|
if(err){ |
|
|
|
console.log(err); |
|
|
|
} else { |
|
|
|
const db = client.db('fluent'); |
|
|
|
db.collection('logs', onCollection); |
|
|
|
var stream = db.collection('logs').find({}, { |
|
|
|
tailable: true, |
|
|
|
awaitdata: true |
|
|
|
/* other options */ |
|
|
|
}).stream(); |
|
|
|
|
|
|
|
stream.on('data', function (doc) { |
|
|
|
console.log('doc ' + JSON.stringify(doc)) |
|
|
|
//socket.write(JSON.stringify({'action': 'log','param': doc.log}));
|
|
|
|
}); |
|
|
|
/* |
|
|
|
db.collection(function(err, collections) { |
|
|
|
collections.forEach(function(coll) { |
|
|
|
console.log(coll.s.name); |
|
|
|
}); |
|
|
|
const db = client.db('fluent'); |
|
|
|
db.collection('logs', onCollection); |
|
|
|
/* |
|
|
|
var stream = db.collection('logs').find({}, { |
|
|
|
tailable: true, |
|
|
|
awaitdata: true |
|
|
|
//other options
|
|
|
|
}).stream(); |
|
|
|
|
|
|
|
stream.on('data', function (doc) { |
|
|
|
console.log('doc ' + JSON.stringify(doc)) |
|
|
|
}); |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|