Browse Source

added experimental shepherd cli route

all-modes
Petr Balashov 8 years ago
parent
commit
3fd093041e
  1. 4
      main.js
  2. 44
      routes/shepherd.js

4
main.js

@ -298,10 +298,10 @@ function createWindow (status) {
if (appConfig.edexGuiOnly) {
if (appConfig.v2) {
shepherd.writeLog('show edex gui');
//mainWindow.loadURL('http://127.0.0.1:3000');
mainWindow.loadURL('http://127.0.0.1:3000');
mainWindow.appConfig = appConfig;
mainWindow.appSessionHash = appSessionHash;
mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.agamaPort + '/gui/EasyDEX-GUI/react/build');
// mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.agamaPort + '/gui/EasyDEX-GUI/react/build');
} else {
shepherd.writeLog('show edex gui');
mainWindow.loadURL('http://' + appConfig.host + ':' + appConfig.agamaPort + '/gui/EasyDEX-GUI/');

44
routes/shepherd.js

@ -280,6 +280,50 @@ shepherd.quitKomodod = function(chain) {
});
}
/*
* type: POST
* params: payload
*/
shepherd.post('/cli', function(req, res, next) {
if (!req.body.payload) {
const errorObj = {
'msg': 'error',
'result': 'no payload provided'
};
res.end(JSON.stringify(errorObj));
} else {
const _mode = req.body.payload.mode === 'passthru' ? 'passthru' : 'default';
const _chain = req.body.payload.chain ? req.body.payload.chain : '';
const _cmd = req.body.payload.cmd;
exec(komodocliBin + (_chain ? ' ac_name=' + _chain : '') + ' ' + _cmd, function(error, stdout, stderr) {
console.log('stdout: ' + stdout)
console.log('stderr: ' + stderr)
if (error !== null) {
console.log('exec error: ' + error)
}
let responseObj;
if (stderr) {
responseObj = {
'msg': 'error',
'result': stderr
};
} else {
responseObj = {
'msg': 'success',
'result': stdout
};
}
res.end(JSON.stringify(responseObj));
});
}
});
/*
* type: POST
* params: payload

Loading…
Cancel
Save