Commit c9d5bb69 authored by priit's avatar priit
Browse files

Logimise parendamine

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