From 7319e156cc200d31b27ec9da78766d928d589c52 Mon Sep 17 00:00:00 2001 From: VSORC Date: Wed, 9 Oct 2019 20:21:38 -0400 Subject: [PATCH] se intento agregar encender el vsorc desde la web --- fifo | 0 src/routes/index.js | 29 +++++++++++++++++++++++++---- src/views/starter.ejs | 14 +++++++++++++- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 fifo 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 @@ +