Update server.js
This commit is contained in:
parent
072a72cedd
commit
9d40a529df
27
server.js
27
server.js
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue