diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-05-26 15:58:21 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-05-26 15:58:21 +0200 |
| commit | 96e19464f98b868bd93b76ac842ec5b32a17cfb6 (patch) | |
| tree | a232cfecd631d49fae8d1402371a284296aeec87 /app/relay/index.js | |
| parent | 28f4bd59314df8162548a1100b280bd256436eaa (diff) | |
means to run remote commands and get output
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) { |
