From 0c9a10cabcd2cb63b7b1ccde10ccea737cc31e56 Mon Sep 17 00:00:00 2001 From: zeus Date: Wed, 25 Nov 2020 20:56:20 +0200 Subject: [PATCH] redis --- swarmlab-app/src/run/app.js | 92 +++++++++++++++---------------------- 1 file changed, 38 insertions(+), 54 deletions(-) diff --git a/swarmlab-app/src/run/app.js b/swarmlab-app/src/run/app.js index f083c25..01a8f0e 100755 --- a/swarmlab-app/src/run/app.js +++ b/swarmlab-app/src/run/app.js @@ -427,64 +427,49 @@ function onCollection(err, collection) { (async() => { var token = "d2539e5a7ae1f9f1b0eb2b8f22ca467a86d28407"; // desto var resdata = await getpipelines(token,pathfile) - console.log('------------------------------ ' + JSON.stringify(resdata.data)) resob.pathlogfile = pathfileval var resobarray = [] - //for (let i in resdata.data) { - var resob1 = {} - var i = 0 - resob1.data = resdata.data[i].res25swarmlabname - resob1.user25user = resdata.data[i].res25user - resob1.res25creator = resdata.data[i].res25creator - resob1.res25fileforce = resdata.data[i].res25fileforce - resob1.tailed_path = pathfileval - resobarray.push(resob1) - var resob1string = JSON.stringify(resob1); - console.log('+++++++++++++++++' + resob1string + '<<<<<<<<<<<<<<<<<<<<<<' + pathfileval); - //pubClient.hmset(pathfileval,resob1string) - pubClient.set(pathfileval, resob1string, function(err, res) { - - }); - await pubClient.get(pathfileval, function(err, object) { - console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> '+JSON.stringify(object)); - }); - //} - resob.data = resobarray - //var indexfind = global.pipelines.findIndex(x => x.res25swarmlabname==resdata.data[0].res25swarmlabname); - //var indexfind = global.pipelines.findIndex(x => x.pathlogfile==pathfileval); - - //indexfind === -1 ? global.pipelines.push({resob}) : console.log("object already exists") - //indexfind === -1 ? global.pipelines.push(resob) : console.log("object already exists "+pathfileval) - - reslog.log = data - reslog.date = convertDateToUTC(now) - //console.log('data ' + JSON.stringify(reslog)); - //var usertmp = global.pipelines.find(x => x.pathlogfile==pathfileval); - //var user = usertmp.data[0].user25user; - await pubClient.get(pathfileval, function(err, object) { - console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> '+JSON.stringify(object)); - var user = object.user25user - }); - console.log('datauser ' + JSON.stringify(user)); - io.in(user).emit("logdata", reslog); - itemsProcessed++; - + var resob1 = {} + var i = 0 + resob1.data = resdata.data[i].res25swarmlabname + resob1.user25user = resdata.data[i].res25user + resob1.res25creator = resdata.data[i].res25creator + resob1.res25fileforce = resdata.data[i].res25fileforce + resob1.tailed_path = pathfileval + //resobarray.push(resob1) + var resob1string = JSON.stringify(resob1); + console.log('+++++++++++++++++' + resob1string + '<<<<<<<<<<<<<<<<<<<<<<' + pathfileval); + await pubClient.set(pathfileval, resob1string, function(err, res) { + }); + reslog.data = resob1 + reslog.log = data + reslog.date = convertDateToUTC(now) + console.log('>>>11111111111111>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> '+JSON.stringify(object)); + var user = resob1.res25creator + console.log('datauser ' + JSON.stringify(user)); + io.in(user).emit("logdata", reslog); + itemsProcessed++; })() }else{ - reslog.log = data - reslog.date = convertDateToUTC(now) - //console.log('dataelse ' + JSON.stringify(reslog)); - //var usertmp = global.pipelines.find(x => x.pathlogfile==pathfileval); - //var user = usertmp.data[0].user25user; - ///console.log('datauser ' + JSON.stringify(user)); - //var user = "anagnostopoulos@uniwa.gr" - pubClient.get(pathfileval, function(err, object) { - console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> '+JSON.stringify(object)); - var user = object.user25user - }); - io.in(user).emit("logdata", reslog); - itemsProcessed++; + pubClient.get(pathfileval, function(err, object) { + var resob1 = {} + var i = 0 + resob1.data = object.res25swarmlabname + resob1.user25user = object.res25user + resob1.res25creator = object.res25creator + resob1.res25fileforce = object.res25fileforce + resob1.tailed_path = object.tailed_path + + reslog.data = resob1 + reslog.log = data + reslog.date = convertDateToUTC(now) + + console.log('>>>>>>>>>>2222222222222>>>>>>>>>>>>>>>>>>>>>>>>>>>>> '+JSON.stringify(object)); + var user = object.user25user + io.in(user).emit("logdata", reslog); + itemsProcessed++; + }); } }); @@ -500,7 +485,6 @@ function onCollection(err, collection) { useNewUrlParser: true, useUnifiedTopology: true }; - //var mongolab_uri = "mongodb://:@:,:/?replicaSet="; var mongooptions = { autoReconnect: true, keepAlive: 1,