summaryrefslogtreecommitdiff
path: root/app/relay/runner.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/relay/runner.js')
-rw-r--r--app/relay/runner.js26
1 files changed, 24 insertions, 2 deletions
diff --git a/app/relay/runner.js b/app/relay/runner.js
index caa2ded..715be7b 100644
--- a/app/relay/runner.js
+++ b/app/relay/runner.js
@@ -1,7 +1,7 @@
// monitors which process is currently running
// kills it if need be.... murder
-import { spawn } from 'child_process'
+import { execFile, spawn } from 'child_process'
import interpreters from './interpreters'
import modules from './modules'
import { kill } from 'tree-kill'
@@ -43,6 +43,21 @@ export function build_params(module, task) {
}
}
+export function run_system_command(cmd, cb) {
+ console.log('running system command:', cmd)
+ switch(cmd) {
+ case 'nvidia-smi':
+ case 'ps':
+ case 'uptime':
+ case 'w':
+ execFile(cmd, cb)
+ break
+ default:
+ cb({ error: 'no such command' })
+ break
+ }
+}
+
export function run_task(module_name, task){
const module = modules['module_name']
if (! module) throw new Error("No such module")
@@ -52,9 +67,16 @@ export function run_task(module_name, task){
const subprocess = spawn(activity.interpreter, params)
if (activity.gpu) {
state.current_gpu_task = subprocess
- } else {
+ }
+ else {
state.current_cpu_task = subprocess
}
+ subprocess.stdout.on('data', data => {
+ console.log('stdout', subprocess.pid, data)
+ })
+ subprocess.stderr.on('data', data => {
+ console.log('stderr', subprocess.pid, data)
+ })
subprocess.on('error', (err) => {
console.log('process error', subprocess.pid, err)
})