From 52a99203812259e814afb138a8692a3f3892591d Mon Sep 17 00:00:00 2001 From: Felix Date: Tue, 19 Nov 2019 01:11:27 +0000 Subject: [PATCH] added new buttons --- src/routes/index.js | 26 +++++++++++++------------- src/views/starter.ejs | 14 ++++++++++---- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/routes/index.js b/src/routes/index.js index 5b5f42a..45b7350 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -75,7 +75,7 @@ router.get('/iperf', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && echo iperf > fifo", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && echo iperf > fifo", function(error, stdout, stderr) { console.log("pingall"); res.send(stdout); }); @@ -84,7 +84,7 @@ router.get('/pingall', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && echo pingall > fifo", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && echo pingall > fifo", function(error, stdout, stderr) { console.log("pingall"); res.send(stdout); }); @@ -93,7 +93,7 @@ router.get('/placement', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && echo placement > fifo", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && echo placement > fifo", function(error, stdout, stderr) { console.log("placement"); res.send(stdout); }); @@ -103,7 +103,7 @@ router.get('/getvsorcdata', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && cat aichivo 2>&1", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && cat aichivo 2>&1", function(error, stdout, stderr) { console.log("getting vsorc data"); res.send(stdout); }); @@ -112,7 +112,7 @@ router.get('/getcontrollerdata', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && cat controllerout 2>&1", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && cat controllerout 2>&1", function(error, stdout, stderr) { console.log("getting controller data"); res.send(stdout); }); @@ -160,7 +160,7 @@ router.get('/startcontroller', (req, res) => { var child; //cd /home/pi && setsid $(cat /home/pi/ejecutarcontroller.sh | grep sudo) >/dev/null 2>&1 < /dev/null & //cd /home/pi && ./ejecutarcontroller.sh > /dev/null 2>&1 < /dev/null & //comando anterior - child = exec("cd /home/pi && touch controllerout && ./ejecutarcontroller.sh > controllerout 2>&1 &", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && touch controllerout && ./ejecutarcontroller.sh > controllerout 2>&1 &", function(error, stdout, stderr) { console.log("controller started"); res.send(stdout); }); @@ -170,7 +170,7 @@ router.get('/stopcontroller', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && rm controllerout && sudo kill $(ps aux | grep python | grep ryu | awk {'print $2'})", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && rm controllerout && sudo kill $(ps aux | grep python | grep ryu | awk {'print $2'})", function(error, stdout, stderr) { console.log("controller stopped"); res.send(stdout); }); @@ -187,20 +187,20 @@ router.get('/startvsorc', (req, res) => { 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 && echo \""+request+"\" > data", function(error, stdout, stderr) { + child0 = exec("cd /home/pi/scripts && echo \""+request+"\" > data", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; }); - child1 = exec("cd /home/pi && mkfifo fifo && touch aichivo", function(error, stdout, stderr) { + child1 = exec("cd /home/pi/scripts && mkfifo fifo && touch aichivo", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; }); - child2 = exec("exec 3>fifo", function(error, stdout, stderr) { + child2 = exec("cd /home/pi/scripts && 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) { + child3 = exec("cd /home/pi/scripts && tail -n +1 -f fifo | sudo ./clusterGRE.py > aichivo 2>&1 &", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; }); @@ -215,7 +215,7 @@ router.get('/stopvsorc', (req,res) =>{ var child3; var payload console.log("erasing..."); - child1 = exec("cd /home/pi && exec 3>&- && rm fifo && rm aichivo", function(error, stdout, stderr) { + child1 = exec("cd /home/pi/scripts && exec 3>&- && rm fifo && rm aichivo", function(error, stdout, stderr) { console.log(stdout); payload+="rm done\n\n"+stdout; @@ -228,7 +228,7 @@ router.get('/stopvsorc', (req,res) =>{ payload+="killed\n\n"+stdout; }); console.log("Multisshing and cleaning..."); - child3 = exec("cd /home/pi && ./multissh.sh sudo -E mn -c; sudo -E mn -c", function(error, stdout, stderr) { + child3 = exec("cd /home/pi/scripts && ./multissh.sh sudo -E mn -c; sudo -E mn -c", function(error, stdout, stderr) { console.log(stdout); console.log("multisshed"); payload+="Multisshed\n\n"+stdout; diff --git a/src/views/starter.ejs b/src/views/starter.ejs index c760c6b..59c535b 100644 --- a/src/views/starter.ejs +++ b/src/views/starter.ejs @@ -42,6 +42,9 @@ + + + @@ -72,6 +75,9 @@ let intervalController = null;//Para tener el id del interval para obtener data del controller let intervalVsorc = null; //Para tener el id del interval para obtener data del vsorc + intervalVsorc = setInterval(getvsorcdata, timeVsorc); + intervalController=setInterval(getcontrollerdata, timeController); + function startcontroller() { let xhr = new XMLHttpRequest(); xhr.open('GET', '/startcontroller', true); @@ -82,7 +88,7 @@ } } xhr.send(); - intervalController=setInterval(getcontrollerdata, timeController); + } function stopcontroller() { @@ -95,7 +101,7 @@ } } xhr.send(); - clearInterval(intervalController); + //clearInterval(intervalController); controllerout.value=''; } function getcontrollerdata() { @@ -124,7 +130,7 @@ } } xhr.send(); - intervalVsorc = setInterval(getvsorcdata, timeVsorc); + } function stopvsorc() { @@ -138,7 +144,7 @@ } } xhr.send(); - clearInterval(intervalVsorc); + //clearInterval(intervalVsorc); vsorcout.value=''; } -- 2.25.1