Merge pull request #576 from CartoDB/conf-analysis-logger
Pass logger configuration to analysis backend and create a stream
This commit is contained in:
commit
16fbd25a34
@ -210,6 +210,12 @@ var config = {
|
|||||||
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
||||||
// the template to use for adding the host header in the batch api requests
|
// the template to use for adding the host header in the batch api requests
|
||||||
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
||||||
|
},
|
||||||
|
logger: {
|
||||||
|
// If filename is given logs comming from analysis client will be written
|
||||||
|
// there, in append mode. Otherwise 'log_filename' is used. Otherwise stdout is used (default).
|
||||||
|
// Log file will be re-opened on receiving the HUP signal
|
||||||
|
filename: '/tmp/analysis.log'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,millstone: {
|
,millstone: {
|
||||||
|
@ -204,6 +204,12 @@ var config = {
|
|||||||
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
||||||
// the template to use for adding the host header in the batch api requests
|
// the template to use for adding the host header in the batch api requests
|
||||||
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
||||||
|
},
|
||||||
|
logger: {
|
||||||
|
// If filename is given logs comming from analysis client will be written
|
||||||
|
// there, in append mode. Otherwise 'log_filename' is used. Otherwise stdout is used (default).
|
||||||
|
// Log file will be re-opened on receiving the HUP signal
|
||||||
|
filename: 'logs/analysis.log'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,millstone: {
|
,millstone: {
|
||||||
|
@ -204,6 +204,12 @@ var config = {
|
|||||||
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
||||||
// the template to use for adding the host header in the batch api requests
|
// the template to use for adding the host header in the batch api requests
|
||||||
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
||||||
|
},
|
||||||
|
logger: {
|
||||||
|
// If filename is given logs comming from analysis client will be written
|
||||||
|
// there, in append mode. Otherwise 'log_filename' is used. Otherwise stdout is used (default).
|
||||||
|
// Log file will be re-opened on receiving the HUP signal
|
||||||
|
filename: 'logs/analysis.log'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,millstone: {
|
,millstone: {
|
||||||
|
@ -205,6 +205,12 @@ var config = {
|
|||||||
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
||||||
// the template to use for adding the host header in the batch api requests
|
// the template to use for adding the host header in the batch api requests
|
||||||
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
||||||
|
},
|
||||||
|
logger: {
|
||||||
|
// If filename is given logs comming from analysis client will be written
|
||||||
|
// there, in append mode. Otherwise 'log_filename' is used. Otherwise stdout is used (default).
|
||||||
|
// Log file will be re-opened on receiving the HUP signal
|
||||||
|
filename: 'node-windshaft.log'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,millstone: {
|
,millstone: {
|
||||||
|
@ -1,19 +1,50 @@
|
|||||||
var camshaft = require('camshaft');
|
var camshaft = require('camshaft');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
function AnalysisBackend(options) {
|
function AnalysisBackend (options) {
|
||||||
var batchConfig = options.batch || {};
|
options = options || {};
|
||||||
|
this.setBatchConfig(options.batch);
|
||||||
|
this.setLoggerConfig(options.logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = AnalysisBackend;
|
||||||
|
|
||||||
|
AnalysisBackend.prototype.setBatchConfig = function (options) {
|
||||||
|
var batchConfig = options || {};
|
||||||
batchConfig.endpoint = batchConfig.endpoint || 'http://127.0.0.1:8080/api/v1/sql/job';
|
batchConfig.endpoint = batchConfig.endpoint || 'http://127.0.0.1:8080/api/v1/sql/job';
|
||||||
batchConfig.inlineExecution = batchConfig.inlineExecution || false;
|
batchConfig.inlineExecution = batchConfig.inlineExecution || false;
|
||||||
batchConfig.hostHeaderTemplate = batchConfig.hostHeaderTemplate || '{{=it.username}}.localhost.lan';
|
batchConfig.hostHeaderTemplate = batchConfig.hostHeaderTemplate || '{{=it.username}}.localhost.lan';
|
||||||
this.batchConfig = batchConfig;
|
this.batchConfig = batchConfig;
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports = AnalysisBackend;
|
AnalysisBackend.prototype.setLoggerConfig = function (options) {
|
||||||
|
var loggerConfig = options || {};
|
||||||
|
|
||||||
|
loggerConfig.filename = loggerConfig.filename;
|
||||||
|
|
||||||
|
this.loggerConfig = loggerConfig;
|
||||||
|
|
||||||
|
if (this.loggerConfig.filename) {
|
||||||
|
this.stream = fs.createWriteStream(this.loggerConfig.filename, { flags: 'a', encoding: 'utf8' });
|
||||||
|
|
||||||
|
process.on('SIGHUP', function () {
|
||||||
|
if (this.stream) {
|
||||||
|
this.stream.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.stream = fs.createWriteStream(this.loggerConfig.filename, { flags: 'a', encoding: 'utf8' });
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
AnalysisBackend.prototype.create = function(analysisConfiguration, analysisDefinition, callback) {
|
AnalysisBackend.prototype.create = function(analysisConfiguration, analysisDefinition, callback) {
|
||||||
analysisConfiguration.batch.endpoint = this.batchConfig.endpoint;
|
analysisConfiguration.batch.endpoint = this.batchConfig.endpoint;
|
||||||
analysisConfiguration.batch.inlineExecution = this.batchConfig.inlineExecution;
|
analysisConfiguration.batch.inlineExecution = this.batchConfig.inlineExecution;
|
||||||
analysisConfiguration.batch.hostHeaderTemplate = this.batchConfig.hostHeaderTemplate;
|
analysisConfiguration.batch.hostHeaderTemplate = this.batchConfig.hostHeaderTemplate;
|
||||||
|
|
||||||
|
analysisConfiguration.logger = {
|
||||||
|
stream: this.stream ? this.stream : process.stdout
|
||||||
|
};
|
||||||
|
|
||||||
camshaft.create(analysisConfiguration, analysisDefinition, callback);
|
camshaft.create(analysisConfiguration, analysisDefinition, callback);
|
||||||
};
|
};
|
||||||
|
@ -147,6 +147,7 @@ module.exports = function(serverOptions) {
|
|||||||
var tileBackend = new windshaft.backend.Tile(rendererCache);
|
var tileBackend = new windshaft.backend.Tile(rendererCache);
|
||||||
var mapValidatorBackend = new windshaft.backend.MapValidator(tileBackend, attributesBackend);
|
var mapValidatorBackend = new windshaft.backend.MapValidator(tileBackend, attributesBackend);
|
||||||
var mapBackend = new windshaft.backend.Map(rendererCache, mapStore, mapValidatorBackend);
|
var mapBackend = new windshaft.backend.Map(rendererCache, mapStore, mapValidatorBackend);
|
||||||
|
|
||||||
var analysisBackend = new AnalysisBackend(serverOptions.analysis);
|
var analysisBackend = new AnalysisBackend(serverOptions.analysis);
|
||||||
|
|
||||||
var layergroupAffectedTablesCache = new LayergroupAffectedTablesCache();
|
var layergroupAffectedTablesCache = new LayergroupAffectedTablesCache();
|
||||||
|
@ -36,6 +36,9 @@ var analysisConfig = _.defaults(global.environment.analysis || {}, {
|
|||||||
inlineExecution: false,
|
inlineExecution: false,
|
||||||
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
endpoint: 'http://127.0.0.1:8080/api/v2/sql/job',
|
||||||
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
hostHeaderTemplate: '{{=it.username}}.localhost.lan'
|
||||||
|
},
|
||||||
|
logger: {
|
||||||
|
filename: undefined
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -95,6 +98,9 @@ module.exports = {
|
|||||||
inlineExecution: analysisConfig.batch.inlineExecution,
|
inlineExecution: analysisConfig.batch.inlineExecution,
|
||||||
endpoint: analysisConfig.batch.endpoint,
|
endpoint: analysisConfig.batch.endpoint,
|
||||||
hostHeaderTemplate: analysisConfig.batch.hostHeaderTemplate
|
hostHeaderTemplate: analysisConfig.batch.hostHeaderTemplate
|
||||||
|
},
|
||||||
|
logger: {
|
||||||
|
filename: analysisConfig.logger.filename
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Do not send unwatch on release. See http://github.com/CartoDB/Windshaft-cartodb/issues/161
|
// Do not send unwatch on release. See http://github.com/CartoDB/Windshaft-cartodb/issues/161
|
||||||
|
Loading…
Reference in New Issue
Block a user