From a25b262be32df467985c519a732ad32ca1362476 Mon Sep 17 00:00:00 2001 From: Felix Date: Tue, 29 Oct 2019 01:29:23 +0000 Subject: [PATCH] create topo from web finished --- npm-debug.log | 26 -------------------------- src/routes/index.js | 21 +++++++++++++++------ src/views/starter.ejs | 11 ++++++++++- 3 files changed, 25 insertions(+), 33 deletions(-) delete mode 100644 npm-debug.log diff --git a/npm-debug.log b/npm-debug.log deleted file mode 100644 index a2cfa34..0000000 --- a/npm-debug.log +++ /dev/null @@ -1,26 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] -2 info using npm@1.4.21 -3 info using node@v8.11.1 -4 verbose run-script [ 'prestart', 'start', 'poststart' ] -5 info prestart web@1.0.0 -6 info start web@1.0.0 -7 verbose unsafe-perm in lifecycle true -8 info web@1.0.0 Failed to exec start script -9 error web@1.0.0 start: `node src/index.js` -9 error Exit status 1 -10 error Failed at the web@1.0.0 start script. -10 error This is most likely a problem with the web package, -10 error not with npm itself. -10 error Tell the author that this fails on your system: -10 error node src/index.js -10 error You can get their info via: -10 error npm owner ls web -10 error There is likely additional logging output above. -11 error System Linux 4.19.57-v7+ -12 error command "/usr/bin/node" "/usr/bin/npm" "start" -13 error cwd /home/pi/VSoRC -14 error node -v v8.11.1 -15 error npm -v 1.4.21 -16 error code ELIFECYCLE -17 verbose exit [ 1, true ] diff --git a/src/routes/index.js b/src/routes/index.js index 7a36b4f..762d14b 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -103,7 +103,8 @@ router.get('/startcontroller', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi/ryu && setsid $(cat /home/pi/ryu/ejecutarcontroller.sh | grep sudo) >/dev/null 2>&1 < /dev/null &", function(error, stdout, stderr) { + //cd /home/pi && setsid $(cat /home/pi/ejecutarcontroller.sh | grep sudo) >/dev/null 2>&1 < /dev/null & + child = exec("cd /home/pi && ./ejecutarcontroller.sh > /dev/null 2>&1 < /dev/null &", function(error, stdout, stderr) { console.log("controller started"); res.send(stdout); }); @@ -125,17 +126,25 @@ router.get('/startvsorc', (req, res) => { var child0;//needs a mkfifo named fifo to exist var child1; var child2; + var child3; var answer; + request = JSON.parse(req.query.topology) + console.log("Topology is : \n"+ request); //controlar que solo se haga un arranque por vez y agregar el exec 3>fifo - child0 = exec("cd /home/pi && mkfifo fifo && touch aichivo", function(error, stdout, stderr) { + child0 = exec("cd /home/pi && echo \""+request+"\" > data", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; }); - child1 = exec("exec 3>fifo", function(error, stdout, stderr) { + child1 = exec("cd /home/pi && mkfifo fifo && rm aichivo && touch aichivo", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; - });//add disown? - child2 = exec("cd /home/pi && cat fifo | sudo ./clusterGRE.py > aichivo 2>&1 &", function(error, stdout, stderr) { + }); + child2 = exec("exec 3>fifo", function(error, stdout, stderr) { + console.log(stdout + stderr); + answer+=stdout; + }); + //child3 uses tail so it can read from fifo even after a EOF + child3 = exec("cd /home/pi && tail -n +1 -f fifo | sudo ./clusterGRE.py > aichivo 2>&1 &", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; }); @@ -149,7 +158,7 @@ router.get('/stopvsorc', (req,res) =>{ var child2; var child3; var payload - child1 = exec("cd /home/pi && exec 3>&- && rm fifo aichivo", function(error, stdout, stderr) { + child1 = exec("cd /home/pi && exec 3>&- && rm fifo", function(error, stdout, stderr) { console.log(stdout); console.log("rm done"); payload+="rm done\n\n"+stdout; diff --git a/src/views/starter.ejs b/src/views/starter.ejs index de1868b..590668c 100644 --- a/src/views/starter.ejs +++ b/src/views/starter.ejs @@ -47,7 +47,11 @@ +