diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-05 03:43:09 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-05 03:43:09 +0200 |
| commit | 4298d8d81c9bea0fb4c0f115dfa2b04ea72f0006 (patch) | |
| tree | 27ca33f462123757e541b4eef080d834e18ceb1d /app | |
| parent | 51d9212d97e3b326a8e9e6499bc83d27df2ef64c (diff) | |
kill cleanly
Diffstat (limited to 'app')
| -rw-r--r-- | app/client/system/system.component.js | 14 | ||||
| -rw-r--r-- | app/client/system/system.reducer.js | 16 | ||||
| -rw-r--r-- | app/relay/runner.js | 15 |
3 files changed, 29 insertions, 16 deletions
diff --git a/app/client/system/system.component.js b/app/client/system/system.component.js index bf77237..10ec971 100644 --- a/app/client/system/system.component.js +++ b/app/client/system/system.component.js @@ -76,6 +76,16 @@ class System extends Component { <button onClick={() => actions.system.run('df')}>df</button> </Param> </Group> + <Group title="Tasks"> + <Param title='Kill task'> + <button onClick={() => actions.queue.stop_task('cpu')}>CPU</button> + <button onClick={() => actions.queue.stop_task('gpu')}>GPU</button> + </Param> + <Param title='Queue'> + <button onClick={() => actions.queue.start_queue()}>Start</button> + <button onClick={() => actions.queue.stop_queue()}>Stop</button> + </Param> + </Group> <Group title="Test"> <Param title='CPU Test Task'> <button onClick={() => actions.queue.start_task(cpu_test_task, { preempt: true, watch: true })}>Start</button> @@ -93,10 +103,6 @@ class System extends Component { <button onClick={() => actions.live.get_params()}>Get</button> <button onClick={() => actions.live.set_param('fruit', choice(fruits))}>Set</button> </Param> - <Param title='Queue'> - <button onClick={() => actions.queue.start_queue()}>Start</button> - <button onClick={() => actions.queue.stop_queue()}>Stop</button> - </Param> <Param title=''> <button onClick={() => actions.system.enqueue_test_task(choice(fruits))}>+Add</button> </Param> diff --git a/app/client/system/system.reducer.js b/app/client/system/system.reducer.js index 27c248a..c20bf93 100644 --- a/app/client/system/system.reducer.js +++ b/app/client/system/system.reducer.js @@ -44,6 +44,7 @@ const systemInitialState = { } const systemReducer = (state = systemInitialState, action) => { + let processor = null switch(action.type) { case types.socket.connect: case types.socket.reconnecting: @@ -174,8 +175,13 @@ const systemReducer = (state = systemInitialState, action) => { stderr: "", } case types.task.task_finish: - if (state.runner[action.task.processor].task.uuid !== action.task.uuid) { - return state + if (state.runner.cpu.task.uuid === action.task.uuid) { + processor = 'cpu' + } + else if (state.runner.gpu.task.uuid === action.task.uuid) { + processor = 'gpu' + } else { + processor = null } return { ...state, @@ -184,10 +190,10 @@ const systemReducer = (state = systemInitialState, action) => { status: "disconnected", error: null, }, - runner: { + runner: processor ? { ...state.runner, - [action.task.processor]: { status: 'IDLE', task: {} }, - }, + [processor]: { status: 'IDLE', task: {} }, + } : state.runner, } case types.app.change_tool: return { diff --git a/app/relay/runner.js b/app/relay/runner.js index 019f25c..6cb582d 100644 --- a/app/relay/runner.js +++ b/app/relay/runner.js @@ -46,6 +46,7 @@ function serialize_task(t){ pid: t.subprocess.pid, } } + function clear_task(is_gpu, task){ if (is_gpu) { if (state.current_gpu_task.task && state.current_gpu_task.task.uuid === task.uuid) { @@ -323,21 +324,21 @@ export function run_next_task(){ export function stop_task(task){ if (!task) return - if (state.current_cpu_task.task.uuid === task.uuid) { + if (task === 'cpu' || state.current_cpu_task.task.uuid === task.uuid) { terminate(state.current_cpu_task) return { status: 'ok' } - } else if (state.current_gpu_task.task.uuid === task.uuid) { + } else if (task === 'gpu' || state.current_gpu_task.task.uuid === task.uuid) { terminate(state.current_gpu_task) return { status: 'ok' } } return { error: 'no such task' } } -export function terminate(task){ - if (!task || !task.subprocess) { +export function terminate(processor){ + if (!processor || !processor.subprocess) { return } - console.log('kill pid', task.subprocess.pid) - task.preempted = true - kill(task.subprocess.pid) + console.log('kill pid', processor.subprocess.pid) + processor.task.preempted = true + kill(processor.subprocess.pid) }
\ No newline at end of file |
