Browse Source

async

master
zeus 4 years ago
parent
commit
68797e3cfa
  1. 18
      swarmlab-app/src/run/app.js

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

@ -431,12 +431,12 @@ function onCollection(err, collection) {
var reslog = new Object(); var reslog = new Object();
var now = new Date(); var now = new Date();
cursor.on('data', function (data) { cursor.on('data', function (data) {
(async() => {
var issendob = {}; var issendob = {};
issendob.message = data.message issendob.message = data.message
issendob.tailed_path = data.tailed_path issendob.tailed_path = data.tailed_path
var issend = getSHA256ofJSON(issendob) var issend = getSHA256ofJSON(issendob)
//io.in('anagnostopoulos@uniwa.gr').emit("logdata", data);
console.log('++++++++' + JSON.stringify(data)); console.log('++++++++' + JSON.stringify(data));
@ -446,8 +446,7 @@ function onCollection(err, collection) {
var indexupdate = "yes" var indexupdate = "yes"
var resob = {} var resob = {}
//var indexfind1 = global.pipelines.findIndex(x => x.pathlogfile==pathfileval); await pubClient.get(pathfileval, function(err, object) {
pubClient.get(pathfileval, function(err, object) {
console.log('----------------' + err + '<<<<<<<<<<<<<<<<<<<<<<' + object); console.log('----------------' + err + '<<<<<<<<<<<<<<<<<<<<<<' + object);
if(object){ if(object){
indexupdate = "no" indexupdate = "no"
@ -456,7 +455,6 @@ function onCollection(err, collection) {
} }
console.log('update '+JSON.stringify(indexupdate)); console.log('update '+JSON.stringify(indexupdate));
if (indexupdate == "yes" ){ if (indexupdate == "yes" ){
(async() => {
var token = "d2539e5a7ae1f9f1b0eb2b8f22ca467a86d28407"; // desto var token = "d2539e5a7ae1f9f1b0eb2b8f22ca467a86d28407"; // desto
var resdata = await getpipelines(token,pathfile) var resdata = await getpipelines(token,pathfile)
resob.pathlogfile = pathfileval resob.pathlogfile = pathfileval
@ -477,7 +475,7 @@ function onCollection(err, collection) {
var user = resob1.res25creator var user = resob1.res25creator
console.log('datauser ' + JSON.stringify(user)); console.log('datauser ' + JSON.stringify(user));
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>> '+JSON.stringify(reslog)); console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>> '+JSON.stringify(reslog));
pubClient.get(issend, function(err, object) { await pubClient.get(issend, function(err, object) {
if(err == null){ if(err == null){
pubClient.set(issend, itemsProcessed, function(err, res) { pubClient.set(issend, itemsProcessed, function(err, res) {
io.in(user).emit("logdata", reslog); io.in(user).emit("logdata", reslog);
@ -485,9 +483,8 @@ function onCollection(err, collection) {
} }
itemsProcessed++; itemsProcessed++;
}); });
})()
}else{ }else{
pubClient.get(pathfileval, function(err, object) { await pubClient.get(pathfileval, function(err, object) {
var objecttmp = JSON.parse(object); var objecttmp = JSON.parse(object);
var resob1 = {} var resob1 = {}
resob1.data = objecttmp.res25swarmlabname resob1.data = objecttmp.res25swarmlabname
@ -503,9 +500,7 @@ function onCollection(err, collection) {
console.log('<<<<<<<<<<<---------------------<<<<<<<<<<<<<<<---------------------------<<<<<<<<<<<< '+JSON.stringify(object)); console.log('<<<<<<<<<<<---------------------<<<<<<<<<<<<<<<---------------------------<<<<<<<<<<<< '+JSON.stringify(object));
console.log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< '+JSON.stringify(reslog)); console.log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< '+JSON.stringify(reslog));
var user = objecttmp.user25user var user = objecttmp.user25user
//io.join(user); await pubClient.get(issend, function(err, object) {
//io.to(user).emit(reslog);
pubClient.get(issend, function(err, object) {
if(err == null){ if(err == null){
pubClient.set(issend, itemsProcessed, function(err, res) { pubClient.set(issend, itemsProcessed, function(err, res) {
io.in(user).emit("logdata", reslog); io.in(user).emit("logdata", reslog);
@ -515,7 +510,8 @@ function onCollection(err, collection) {
}); });
}); });
} }
}); }); //redis get
})() //async
}); });

Loading…
Cancel
Save