Browse Source

debug log (wip #2)

all-modes
pbca26 8 years ago
parent
commit
fbfc5ded5e
  1. 10
      private/mainmenu.js
  2. 53
      routes/shepherd.js

10
private/mainmenu.js

@ -44,7 +44,7 @@ const template = [
accelerator: 'CmdOrCtrl+R', accelerator: 'CmdOrCtrl+R',
click (item, focusedWindow) { click (item, focusedWindow) {
if (focusedWindow) if (focusedWindow)
focusedWindow.reload() focusedWindow.reload();
} }
}, },
{ {
@ -52,7 +52,7 @@ const template = [
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I', accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click (item, focusedWindow) { click (item, focusedWindow) {
if (focusedWindow) if (focusedWindow)
focusedWindow.webContents.toggleDevTools() focusedWindow.webContents.toggleDevTools();
} }
}, },
{ {
@ -96,7 +96,7 @@ const template = [
if (process.platform === 'linux') { if (process.platform === 'linux') {
require('child_process').exec('xdg-open http://support.supernet.org'); require('child_process').exec('xdg-open http://support.supernet.org');
} else { } else {
shell.openExternal('http://support.supernet.org') shell.openExternal('http://support.supernet.org');
} }
} }
}, },
@ -106,7 +106,7 @@ const template = [
if (process.platform === 'linux') { if (process.platform === 'linux') {
require('child_process').exec('xdg-open https://sprnt.slack.com/messages/support'); require('child_process').exec('xdg-open https://sprnt.slack.com/messages/support');
} else { } else {
shell.openExternal('https://sprnt.slack.com/messages/support') shell.openExternal('https://sprnt.slack.com/messages/support');
} }
} }
}, },
@ -116,7 +116,7 @@ const template = [
if (process.platform === 'linux') { if (process.platform === 'linux') {
require('child_process').exec('xdg-open https://github.com/SuperNETorg/iguana/issues'); require('child_process').exec('xdg-open https://github.com/SuperNETorg/iguana/issues');
} else { } else {
shell.openExternal('https://github.com/SuperNETorg/iguana/issues') shell.openExternal('https://github.com/SuperNETorg/iguana/issues');
} }
} }
} }

53
routes/shepherd.js

@ -80,11 +80,33 @@ shepherd.get('/', function(req, res, next) {
}); });
shepherd.get('/appconf', function(req, res, next) { shepherd.get('/appconf', function(req, res, next) {
shepherd.readDebugLog();
var obj = shepherd.loadLocalConfig(); var obj = shepherd.loadLocalConfig();
res.send(obj); res.send(obj);
}); });
shepherd.post('/debuglog', function(req, res) {
var _herd = req.body.herdname,
_lastNLines = req.body.lastLines,
_location;
console.log(req.body.lastLines);
if (_herd === 'iguana') {
_location = iguanaDir;
} else if (_herd === 'komodo') {
_location = komodoDir;
}
shepherd.readDebugLog(_location + '/debug.log', _lastNLines)
.then(function(result) {
var _obj = { 'msg': 'success', 'result': result };
res.send(_obj);
}, function(result) {
var _obj = { 'msg': 'error', 'result': result };
res.send(_obj);
});
});
shepherd.post('/herd', function(req, res) { shepherd.post('/herd', function(req, res) {
console.log('======= req.body ======='); console.log('======= req.body =======');
//console.log(req); //console.log(req);
@ -193,13 +215,24 @@ shepherd.loadLocalConfig = function() {
} }
}; };
shepherd.readDebugLog = function() { shepherd.readDebugLog = function(fileLocation, lastNLines) {
console.log('reading debug.log'); return new Promise(
console.log(komodoDir + '/debug.log'); function(resolve, reject) {
if (lastNLines) {
if (fs.existsSync(fileLocation)) {
console.log('reading ' + fileLocation);
readLastLines readLastLines
.read(komodoDir + '/debug.log', 50) .read(fileLocation, lastNLines)
.then((lines) => console.log(lines)); .then((lines) => resolve(lines));
} else {
reject('file ' + fileLocation + ' doesn\'t exist!');
}
} else {
reject('readDebugLog error: lastNLines param is not provided!');
}
}
);
}; };
function herder(flock, data) { function herder(flock, data) {
@ -271,7 +304,7 @@ function herder(flock, data) {
script: iguanaBin, // path to binary script: iguanaBin, // path to binary
name: 'IGUANA', name: 'IGUANA',
exec_mode : 'fork', exec_mode : 'fork',
cwd: iguanaDir, //set correct iguana directory cwd: iguanaDir //set correct iguana directory
}, function(err, apps) { }, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2 pm2.disconnect(); // Disconnect from PM2
if (err) if (err)
@ -295,7 +328,7 @@ function herder(flock, data) {
name: data.ac_name, // REVS, USD, EUR etc. name: data.ac_name, // REVS, USD, EUR etc.
exec_mode : 'fork', exec_mode : 'fork',
cwd: komodoDir, cwd: komodoDir,
args: data.ac_options, args: data.ac_options
//args: ["-server", "-ac_name=USD", "-addnode=78.47.196.146"], //separate the params with commas //args: ["-server", "-ac_name=USD", "-addnode=78.47.196.146"], //separate the params with commas
}, function(err, apps) { }, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2 pm2.disconnect(); // Disconnect from PM2
@ -317,9 +350,9 @@ function herder(flock, data) {
pm2.start({ pm2.start({
script: CorsProxyBin, // path to binary script: CorsProxyBin, // path to binary
name: 'CORSPROXY', // REVS, USD, EUR etc. name: 'CORSPROXY',
exec_mode : 'fork', exec_mode : 'fork',
cwd: iguanaDir, cwd: iguanaDir
}, function(err, apps) { }, function(err, apps) {
pm2.disconnect(); // Disconnect from PM2 pm2.disconnect(); // Disconnect from PM2
if (err) if (err)

Loading…
Cancel
Save