Browse Source

getlog

master
zeus 4 years ago
parent
commit
0fb2474061
  1. 39
      swarmlab-app/src/run/app.js

39
swarmlab-app/src/run/app.js

@ -291,7 +291,20 @@ app.get('/get_log', [
cors(corsOptions), (req, res, next) => { cors(corsOptions), (req, res, next) => {
(async() => { (async() => {
var RES = new Object();
RES.token = req.query["token"]
RES.start = req.query["start"]
RES.end = req.query["end"]
RES.filter = req.query["filter"]
var isvalid = await checkToken(RES.token);
if(isvalid.action == 'ok'){
console.log("Authserver ok " + RES.token);
RES.error = 'ok'
}else{
console.log("Authserver no " + RES.token);
RES.error = 'no'
}
if(RES.error == 'ok'){
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" 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"
const OPTS = { const OPTS = {
useNewUrlParser: true, useNewUrlParser: true,
@ -312,29 +325,17 @@ MongoClient.connect(mongourl, OPTS, function(err, client){
stream.on('data', function (doc) { stream.on('data', function (doc) {
console.log(JSON.stringify(doc)) console.log(JSON.stringify(doc))
//socket.write(JSON.stringify({'action': 'log','param': doc.log})); //socket.write(JSON.stringify({'action': 'log','param': doc.log}));
var RES = new Object();
RES.token = req.query["token"]
RES.start = req.query["start"]
RES.end = req.query["end"]
RES.filter = req.query["filter"]
var isvalid = await checkToken(RES.token);
if(isvalid.action == 'ok'){
console.log("Authserver ok " + RES.token);
RES.error = 'ok'
}else{
console.log("Authserver no " + RES.token);
RES.error = 'no'
}
RES.error_msg = "ok" RES.error_msg = "ok"
res.json(RES) res.json(RES)
}); });
} }
}); });
}else{
RES.error_msg = "tokeni err"
res.json(RES)
}
})() })()

Loading…
Cancel
Save