Commit c9d5bb69 authored by priit's avatar priit
Browse files

Logimise parendamine

parent b60e7d26
......@@ -6,6 +6,14 @@ var config = require('./wrapper_configs/global');
"level": "ERROR",
"appender": {
"type": "smtp",
"layout": {
type: 'pattern',
pattern: "[%d] [%x{port}-%x{pid}][%5.5p] %c - %m",
tokens: {
pid: process.pid,
port: config.port
}
},
"recipients": "***********",
"sendInterval": 10, //sec
"transport": "SMTP",
......
var logger = require('log4js').getLogger('router_middleware');
var logger = require('log4js').getLogger('error_handler_middleware');
module.exports = {
common: function(err, req, res, next) {
logger.error(err.stack);
logger.error('Common error: ', err);
res.status(err.status || 500);
res.send({
......@@ -11,7 +12,8 @@ module.exports = {
},
error404: function(req, res, next) {
logger.error('Error 404 happened');
logger.debug('Error 404 happened');
res.status(404);
res.send({
errors: 'Lehekülge ei leitud'
......
......@@ -25,7 +25,6 @@ var CleanerService = function () {
};
this.cleanSystem = function () {
logger.debug('clean A');
var folder = config.fs.storagePath;
......@@ -63,8 +62,7 @@ var CleanerService = function () {
logger.debug(filePath);
fs.stat(filePath, function(err, stat) {
if(err){
logger.error(filePath);
logger.error(err);
logger.error(filePath, err);
return continueScan();
}
......
......@@ -14,7 +14,7 @@ var DaoService = function(){
});
this.client.on("error", function (err) {
logger.error("Redis Error " + err);
logger.error("Redis Error ", err);
});
this.set = function(key, value, cb){
......
......@@ -47,6 +47,14 @@ config.log4js = {
"level": "ERROR",
"appender": {
"type": "smtp",
"layout": {
type: 'pattern',
pattern: "[%d] [%x{port}-%x{pid}][%5.5p] %c - %m",
tokens: {
pid: process.pid,
port: config.port
}
},
"recipients": "**********",
"sendInterval": 10, //sec
"transport": "SMTP",
......@@ -129,8 +137,6 @@ var simpleCommandRequest = {
}
};
config.availableCommands = {
TOKENIZER : {
commandTemplate: 'python /var/www/bitweb.ee/keeleliin.bitweb.ee/wrapper/utils/tokenizer/tokenizer.py -i [data] -o [outputPath1]'
......@@ -156,11 +162,12 @@ config.availableCommands = {
};
config.availableWappers = {
TOKENIZER : {
title: 'Sõnestaja',
port: 3008,
class: 'tokenizer',
command: config.availableCommands.TOKENIZER,
LAUSESTAJA : {
title: 'Lausestaja',
port: 3001,
class: 'simpleLocalCommand',
command: config.availableCommands.LAUSESTAJA,
requestConf: simpleCommandRequest
},
MORFANALYSAATOR : {
......@@ -170,26 +177,13 @@ config.availableWappers = {
command: config.availableCommands.MORFANALYSAATOR,
requestConf: simpleCommandRequest
},
LAUSESTAJA : {
title: 'Lausestaja',
port: 3001,
class: 'simpleLocalCommand',
command: config.availableCommands.LAUSESTAJA,
requestConf: simpleCommandRequest
},
OSALAUSESTAJA : {
title: 'Osalausestamine',
title: 'Osalausestaja',
port: 3003,
class: 'simpleLocalCommand',
command: config.availableCommands.OSALAUSESTAJA,
requestConf: simpleCommandRequest
},
ARCHIVE_EXTRACTOR: {
title: 'Arhiivi lahtipakkija',
port: 3007,
class: 'archiveExtractor',
requestConf: simpleCommandRequest
},
MORFYHESTAJA: {
title: 'Morfoloogiline ühestamine (kitsenduste grammatika)',
port: 3004,
......@@ -210,6 +204,21 @@ config.availableWappers = {
class: 'simpleLocalCommand',
command: config.availableCommands.S6LT_SYN,
requestConf: simpleCommandRequest
},
ARCHIVE_EXTRACTOR: {
title: 'Arhiivi lahtipakkija',
port: 3007,
class: 'archiveExtractor',
requestConf: simpleCommandRequest
},
TOKENIZER : {
title: 'Sõnestaja',
port: 3008,
class: 'tokenizer',
command: config.availableCommands.TOKENIZER,
requestConf: simpleCommandRequest
}
};
......
......@@ -36,10 +36,9 @@ app.use(bodyParser.json({limit: '1000mb'})); // for parsing application/json
app.use(multer({ dest: config.fs.tmpPath})); // for parsing multipart/form-data
app.use(express.static(path.join(__dirname, 'public')));
app.use(routerMiddleware.routeLogger);
app.use(errorhandlerMiddleware.common);
app.use(controllers);
app.use(errorhandlerMiddleware.error404);
app.use(errorhandlerMiddleware.common);
/**
* Create HTTP server.
*/
......@@ -56,7 +55,7 @@ function startCluster( instanceCount, cb ){
}
cluster.on('exit', function(worker, code, signal) {
log4jsLogger.info('worker ' + worker.process.pid + ' died; Code: ' + code + '; Signal: ' + signal);
log4jsLogger.error('worker ' + worker.process.pid + ' died; Code: ' + code + '; Signal: ' + signal);
});
cleanerService.init();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment