Nicer logging + Monitoring progress

This commit is contained in:
baldo 2016-05-24 19:14:09 +02:00
parent a82b66c637
commit 09b01f5ccf
5 changed files with 47 additions and 22 deletions

View file

@ -7,7 +7,9 @@
"peersPath": "/tmp/peers",
"logging": {
"directory": "/tmp/logs"
"directory": "/tmp/logs",
"debug": false,
"logRequests": false
},
"email": {
@ -25,7 +27,7 @@
},
"map": {
"nodesJsonUrl": "https://map.hamburg.freifunk.net/nodes.json"
"nodesJsonUrl": "http://musterstadt.freifunk.net/nodes.json"
}
},
"client": {
@ -37,6 +39,9 @@
"map": {
"mapUrl": "http://map.hamburg.freifunk.net"
},
"monitoring": {
"enabled": false
},
"coordsSelector": {
"lat": 53.565278,
"lng": 10.001389,

View file

@ -12,7 +12,9 @@ var defaultConfig = {
peersPath: '/tmp/peers',
logging: {
directory: '/tmp/logs'
directory: '/tmp/logs',
debug: false,
logRequests: false
},
email: {
@ -44,7 +46,7 @@ var defaultConfig = {
mapUrl: 'http://map.musterstadt.freifunk.net'
},
monitoring: {
enabled: true
enabled: false
},
coordsSelector: {
showInfo: false,

View file

@ -8,7 +8,7 @@ _.each(jobFiles, function (jobFile) {
require(jobFile);
});
angular.module('ffffng').factory('Scheduler', function ($injector, Logger) {
angular.module('ffffng').factory('Scheduler', function ($injector, Logger, config) {
var cron = require('node-cron');
function schedule(expr, jobName) {
@ -29,10 +29,13 @@ angular.module('ffffng').factory('Scheduler', function ($injector, Logger) {
try {
schedule('0 */1 * * * *', 'MailQueueJob');
if (config.client.monitoring.enabled) {
// schedule('0 */5 * * * *', 'NodeInformationRetrievalJob');
schedule('*/10 * * * * *', 'NodeInformationRetrievalJob');
// schedule('0 */1 * * * *', 'NodeInformationCleanupJob');
}
}
catch (error) {
Logger.tag('jobs').error('Error during scheduling of background jobs:', error);
throw error;

View file

@ -2,26 +2,34 @@
var config = require('./config');
// Hack to allow proper logging of Error.
Object.defineProperty(Error.prototype, 'message', {
configurable: true,
enumerable: true
});
Object.defineProperty(Error.prototype, 'stack', {
configurable: true,
enumerable: true
});
var scribe = require('scribe-js')({
app: 'ffffng',
id: process.pid,
rootPath: config.server.logging.directory,
module: {
'router/Viewer': {
username: false,
password: false
}
}
});
process.console.addLogger('debug', 'grey', {
if (config.server.logging.debug) {
process.console.addLogger('debug', 'grey', {
logInConsole: false
});
});
} else {
process.console.debug = function () {};
}
angular.module('ffffng').factory('Logger', function (app) {
if (config.server.logging.logRequests) {
app.use(scribe.express.logger());
}
app.use('/internal/logs', scribe.webPanel());
return process.console;

View file

@ -241,6 +241,13 @@ angular.module('ffffng')
return callback(err);
}
if (response.statusCode !== 200) {
return callback(new Error(
'Could not download nodes.json from ' + url + ': ' +
response.statusCode + ' - ' + response.statusMessage
));
}
parseNodesJson(body, function (err, data) {
if (err) {
return callback(err);