summaryrefslogtreecommitdiff
path: root/app/relay/runner.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-06-05 15:03:13 +0200
committerJules Laplace <julescarbon@gmail.com>2018-06-05 15:04:12 +0200
commitba825eb101f8ca1cbf5de7a87c6c2995a0d687a5 (patch)
tree049b6d2cc7d4517f763b357ba29feb2a6cc2e578 /app/relay/runner.js
parent0db903f139aa2eb91308f99bb3be3619c2d9b217 (diff)
du command
Diffstat (limited to 'app/relay/runner.js')
-rw-r--r--app/relay/runner.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/app/relay/runner.js b/app/relay/runner.js
index 6cb582d..99f4a16 100644
--- a/app/relay/runner.js
+++ b/app/relay/runner.js
@@ -121,17 +121,23 @@ export function build_params(module, activity, task) {
}
export function run_system_command(cmd, cb) {
- console.log('running system command:', cmd)
- switch(cmd) {
+ console.log('running system command:', cmd.cmd)
+ switch(cmd.cmd) {
case 'nvidia-smi':
case 'ps':
case 'uptime':
case 'w':
- execFile(cmd, [], cb)
+ execFile(cmd.cmd, [], cb)
break
case 'df':
execFile('df', ['-h'], cb)
break
+ case 'ls':
+ list_directory(cmd, cb)
+ break
+ case 'du':
+ disk_usage(cmd, cb)
+ break
default:
cb({ error: 'no such command' })
break
@@ -167,6 +173,15 @@ export function list_directory(opt, cb) {
})
}
+export function disk_usage(opt, cb) {
+ if (!opt.module || ! modules[opt.module]) {
+ cb([])
+ }
+ const module = modules[opt.module]
+ const dir = path.join(module.cwd, opt.dir.replace(/\.\.?\//g, ''))
+ execFile('du', ['-d', 1, dir], cb)
+}
+
export function run_script(task, cb) {
if (!task.module || ! modules[task.module]) {
cb("")