From: VSORC Date: Thu, 10 Oct 2019 00:21:38 +0000 (-0400) Subject: se intento agregar encender el vsorc desde la web X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=7319e156cc200d31b27ec9da78766d928d589c52;p=VSoRC%2F.git se intento agregar encender el vsorc desde la web --- diff --git a/fifo b/fifo new file mode 100644 index 0000000..e69de29 diff --git a/src/routes/index.js b/src/routes/index.js index c44e2cd..a9299a9 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -71,7 +71,6 @@ router.get('/gettopo', (req, res) => { }); }); - router.get('/startcontroller', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; @@ -93,13 +92,35 @@ router.get('/stopcontroller', (req, res) => { }); router.get('/startvsorc', (req, res) => { + var sys = require('sys') + var exec = require('child_process').exec; + var child0;//needs a mkfifo named fifo to exist + var child1; + var child2; + var answer; + //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) { + console.log(stdout + stderr); + answer+=stdout; + }); + child1 = exec("exec 3>fifo", 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) { + console.log(stdout + stderr); + answer+=stdout; + }); + res.send(answer); +}); + +router.get('/stopvsorc', (req,res) =>{ var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && cat fifo | sudo ./clusterGRE.py > aichivo 2>&1 ", function(error, stdout, stderr) { + child = exec("cd /home/pi && exec 3>&- && rm fifo aichivo", function(error, stdout, stderr) { console.log(stdout); res.send(stdout); - }); + });//esto cierra el fifo, lo cual cierra el programa }); - module.exports = router; diff --git a/src/views/starter.ejs b/src/views/starter.ejs index 5703c0c..de1868b 100644 --- a/src/views/starter.ejs +++ b/src/views/starter.ejs @@ -46,6 +46,7 @@ +