Browse Source

refactored debug.log reader func

all-modes
Petr Balashov 8 years ago
parent
commit
579bd3667e
  1. 2
      package.json
  2. 12
      routes/shepherd.js

2
package.json

@ -29,11 +29,11 @@
"express": "^4.14.0",
"fix-path": "^2.1.0",
"fs-extra": "^1.0.0",
"graceful-fs": "^4.1.11",
"md5": "^2.2.1",
"mkdirp": "^0.5.1",
"pm2": "^2.3.0",
"ps-node": "^0.1.4",
"read-last-lines": "^1.1.0",
"socket.io": "^1.7.3"
}
}

12
routes/shepherd.js

@ -12,7 +12,6 @@ const electron = require('electron'),
exec = require('child_process').exec,
md5 = require('md5'),
pm2 = require('pm2'),
readLastLines = require('read-last-lines'),
request = require('request'),
async = require('async');
@ -783,9 +782,14 @@ shepherd.readDebugLog = function(fileLocation, lastNLines) {
reject('readDebugLog error: ' + err);
} else {
console.log('reading ' + fileLocation);
readLastLines
.read(fileLocation, lastNLines)
.then((lines) => resolve(lines));
_fs.readFile(fileLocation, 'utf-8', function(err, data) {
if (err) throw err;
// TODO: truncate komodod debug.log on app start
var lines = data.trim().split('\n');
var lastLine = lines.slice(lines.length - lastNLines, lines.length).join('\n');
resolve(lastLine);
});
}
});
} else {

Loading…
Cancel
Save