diff options
Diffstat (limited to 'app/relay/index.js')
| -rw-r--r-- | app/relay/index.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/app/relay/index.js b/app/relay/index.js index d43f221..2f93644 100644 --- a/app/relay/index.js +++ b/app/relay/index.js @@ -9,10 +9,7 @@ let remote = io.connect(process.env.SOCKETIO_REMOTE) remote.on('cmd', (data) => { console.log('cmd data', data) - if (! data.cmd) { - console.log('malformed param...?') - return - } + if (! data.cmd) return console.log('malformed param...?') console.log('got', data.cmd) switch (data.cmd) { case 'set_param': @@ -43,6 +40,24 @@ remote.on('cmd', (data) => { } }) +remote.on('system', (data) => { + console.log('system:', data.cmd) + switch(data.cmd) { + case 'run_system_command': + runner.run_system_command(data.payload, (error, stdout, stderr) => { + remote.emit('system_res', { + type: 'command_output', + cmd: data.payload, + error, stdout, stderr + }) + }) + break + default: + remote.emit('system_res', { error: 'unknown system command' }) + break + } +}) + let rpc = new zerorpc.Client() rpc.connect('tcp://127.0.0.1:' + process.env.RPC_PORT) rpc.on('error', function(error) { |
