|
@ -291,50 +291,51 @@ app.get('/get_log', [ |
|
|
cors(corsOptions), (req, res, next) => { |
|
|
cors(corsOptions), (req, res, next) => { |
|
|
|
|
|
|
|
|
(async() => { |
|
|
(async() => { |
|
|
|
|
|
var RES = new Object(); |
|
|
var mongourl = "mongodb://"+CONFIG.mongo.user+":"+CONFIG.mongo.password+"@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&authSource=swarmlabplaygroundstats" |
|
|
RES.token = req.query["token"] |
|
|
const OPTS = { |
|
|
RES.start = req.query["start"] |
|
|
useNewUrlParser: true, |
|
|
RES.end = req.query["end"] |
|
|
useUnifiedTopology: true |
|
|
RES.filter = req.query["filter"] |
|
|
}; |
|
|
var isvalid = await checkToken(RES.token); |
|
|
MongoClient.connect(mongourl, OPTS, function(err, client){ |
|
|
if(isvalid.action == 'ok'){ |
|
|
if(err){ |
|
|
console.log("Authserver ok " + RES.token); |
|
|
console.log(err); |
|
|
RES.error = 'ok' |
|
|
} else { |
|
|
}else{ |
|
|
const db = client.db('fluent'); |
|
|
console.log("Authserver no " + RES.token); |
|
|
//db.collection('log', onCollection);
|
|
|
RES.error = 'no' |
|
|
console.log(JSON.stringify('mongo connected')) |
|
|
} |
|
|
var stream = db.collection('logs').find({}, { |
|
|
if(RES.error == 'ok'){ |
|
|
tailable: true, |
|
|
var mongourl = "mongodb://"+CONFIG.mongo.user+":"+CONFIG.mongo.password+"@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&authSource=swarmlabplaygroundstats" |
|
|
awaitdata: true |
|
|
const OPTS = { |
|
|
}).stream(); |
|
|
useNewUrlParser: true, |
|
|
|
|
|
useUnifiedTopology: true |
|
|
stream.on('data', function (doc) { |
|
|
}; |
|
|
console.log(JSON.stringify(doc)) |
|
|
MongoClient.connect(mongourl, OPTS, function(err, client){ |
|
|
//socket.write(JSON.stringify({'action': 'log','param': doc.log}));
|
|
|
if(err){ |
|
|
|
|
|
console.log(err); |
|
|
|
|
|
} else { |
|
|
var RES = new Object(); |
|
|
const db = client.db('fluent'); |
|
|
RES.token = req.query["token"] |
|
|
//db.collection('log', onCollection);
|
|
|
RES.start = req.query["start"] |
|
|
console.log(JSON.stringify('mongo connected')) |
|
|
RES.end = req.query["end"] |
|
|
var stream = db.collection('logs').find({}, { |
|
|
RES.filter = req.query["filter"] |
|
|
tailable: true, |
|
|
var isvalid = await checkToken(RES.token); |
|
|
awaitdata: true |
|
|
if(isvalid.action == 'ok'){ |
|
|
}).stream(); |
|
|
console.log("Authserver ok " + RES.token); |
|
|
|
|
|
RES.error = 'ok' |
|
|
stream.on('data', function (doc) { |
|
|
}else{ |
|
|
console.log(JSON.stringify(doc)) |
|
|
console.log("Authserver no " + RES.token); |
|
|
//socket.write(JSON.stringify({'action': 'log','param': doc.log}));
|
|
|
RES.error = 'no' |
|
|
RES.error_msg = "ok" |
|
|
|
|
|
res.json(RES) |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
RES.error_msg = "ok" |
|
|
}); |
|
|
res.json(RES) |
|
|
}else{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RES.error_msg = "tokeni err" |
|
|
|
|
|
res.json(RES) |
|
|
|
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
})() |
|
|
})() |
|
|
|
|
|
|
|
|