diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-05-27 00:08:57 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-05-27 00:08:57 +0200 |
| commit | e4957554e777bd9e25097fcb4db40686848a908c (patch) | |
| tree | b9517c09038b7425d78a5b397f7f552d7e933a2d /app/relay | |
| parent | 66dfb9e5ca6b3e2990d9b70314d404074b1be0cb (diff) | |
killing process
Diffstat (limited to 'app/relay')
| -rw-r--r-- | app/relay/runner.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/app/relay/runner.js b/app/relay/runner.js index f15e39b..039bfe7 100644 --- a/app/relay/runner.js +++ b/app/relay/runner.js @@ -4,7 +4,7 @@ import { execFile, spawn } from 'child_process' import interpreters from './interpreters' import modules from './modules' -import { kill } from 'tree-kill' +import kill from 'tree-kill' import { remote } from './remote' export const state = { @@ -82,28 +82,28 @@ export function run_task(task, preempt, watch){ const { activity, interpreter, params } = build_params(module, task) if (! interpreter) return { type: 'error', error: "No such interpreter: " + activity.interpreter } - if (activity.cpu && state.current_cpu_task) { - if (preempt) { - kill_task(state.current_cpu_task) - console.log('preempting currently running CPU task') - } else { - console.log('already running CPU task') - return { type: 'error', error: 'task already running on cpu' } - } - } else if (state.current_gpu_task) { + if (interpreter.gpu && state.current_gpu_task) { if (preempt) { console.log('preempting currently running GPU task') kill_task(state.current_gpu_task) } else { - console.log('already running GPU task', state.current_gpu_task.pid) + console.log('already running GPU task :(', state.current_gpu_task.pid) return { type: 'error', error: 'task already running on gpu' } } + } else if (!interpreter.gpu && state.current_cpu_task) { + if (preempt) { + console.log('preempting currently running CPU task') + kill_task(state.current_cpu_task) + } else { + console.log('already running CPU task :(') + return { type: 'error', error: 'task already running on cpu' } + } } - console.log(activity, interpreter) console.log('running task', task.activity) console.log(module.cwd) console.log(interpreter.cmd, params) + const subprocess = spawn(interpreter.cmd, params, { cwd: module.cwd, }) |
