Update server.js

This commit is contained in:
Thomas Forgione 2019-03-28 11:44:17 +01:00
parent 072a72cedd
commit 9d40a529df
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 25 additions and 2 deletions

View File

@ -18,6 +18,26 @@ try { fs.mkdirSync(aisPathOld); } catch { }
let pythonRunning = false;
let pythonShouldRun = false;
function runPythonTotal() {
let p = spawn(pythonPath, ['run.py'], {cwd: 'pytron_run'});
p.stdout.on('data', (data) => {
let content = data.toString().split('\n');
for (let line of content) {
console.log('run.py: ' + line);
}
});
p.stderr.on('data', (data) => {
let content = data.toString().split('\n');
for (let line of content) {
console.log('run.py: ' + line);
}
});
p.on('close', (code) => {
process.stdout.write('Python finished executing');
});
}
function runPython() {
process.stdout.write('Requested to run python');
if (pythonRunning) {
@ -317,12 +337,15 @@ function main() {
case 'start':
startServer();
break;
case 'python':
case 'refresh':
runPython();
break;
case 'recompute':
runPythonTotal();
break;
default:
console.log('Unknown option: ' + process.argv[2]);
console.log('Usage: node server.js start|python')
console.log('Usage: node server.js start|refresh|recompute')
process.exit(1);
break;
}