2011-09-05 07:00:41 +08:00
|
|
|
/*
|
2011-10-07 22:38:28 +08:00
|
|
|
* Windshaft-CartoDB
|
|
|
|
* ===============
|
|
|
|
*
|
|
|
|
* ./app.js [environment]
|
|
|
|
*
|
|
|
|
* environments: [development, production]
|
|
|
|
*/
|
2011-09-05 07:00:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
// sanity check
|
|
|
|
var ENV = process.argv[2]
|
2013-02-11 20:41:51 +08:00
|
|
|
if (ENV != 'development' && ENV != 'production' && ENV != 'staging' ){
|
2011-10-07 22:38:28 +08:00
|
|
|
console.error("\nnode app.js [environment]");
|
2013-02-11 20:41:51 +08:00
|
|
|
console.error("environments: [development, production, staging]\n");
|
2011-10-07 22:38:28 +08:00
|
|
|
process.exit(1);
|
2011-09-05 07:00:41 +08:00
|
|
|
}
|
|
|
|
|
2011-10-07 22:38:28 +08:00
|
|
|
var _ = require('underscore')
|
|
|
|
, Step = require('step')
|
2011-10-13 19:17:00 +08:00
|
|
|
, CartodbWindshaft = require('./lib/cartodb/cartodb_windshaft');
|
2011-09-05 07:00:41 +08:00
|
|
|
|
|
|
|
// set environment specific variables
|
|
|
|
global.settings = require(__dirname + '/config/settings');
|
|
|
|
global.environment = require(__dirname + '/config/environments/' + ENV);
|
|
|
|
_.extend(global.settings, global.environment);
|
|
|
|
|
2012-07-10 15:49:56 +08:00
|
|
|
// Include cart_data.js only _after_ the "global" variable is set
|
|
|
|
// See https://github.com/Vizzuality/Windshaft-cartodb/issues/28
|
|
|
|
var cartoData = require('./lib/cartodb/carto_data');
|
|
|
|
|
2011-09-05 07:00:41 +08:00
|
|
|
var Windshaft = require('windshaft');
|
|
|
|
var serverOptions = require('./lib/cartodb/server_options');
|
|
|
|
|
2011-10-13 19:17:00 +08:00
|
|
|
ws = CartodbWindshaft(serverOptions);
|
2013-01-30 00:36:50 +08:00
|
|
|
|
|
|
|
// Maximum number of connections for one process
|
|
|
|
// 128 is a good number if you have up to 1024 filedescriptors
|
|
|
|
// 4 is good if you have max 32 filedescriptors
|
|
|
|
// 1 is good if you have max 16 filedescriptors
|
|
|
|
ws.maxConnections = global.environment.maxConnections || 128;
|
|
|
|
|
2012-10-09 23:09:40 +08:00
|
|
|
ws.listen(global.environment.port, global.environment.host);
|
2013-01-30 00:36:50 +08:00
|
|
|
|
2012-10-09 23:09:40 +08:00
|
|
|
ws.on('listening', function() {
|
|
|
|
console.log("Windshaft tileserver started on " + global.environment.host + ':' + global.environment.port);
|
|
|
|
});
|
2013-01-30 18:29:44 +08:00
|
|
|
|
2013-03-18 23:37:31 +08:00
|
|
|
// DEPRECATED, use SIGUSR2
|
2013-01-30 18:29:44 +08:00
|
|
|
process.on('SIGUSR1', function() {
|
2013-03-19 01:14:18 +08:00
|
|
|
console.log('WARNING: handling of SIGUSR1 by Windshaft-CartoDB is deprecated, please send SIGUSR2 instead');
|
2013-01-30 18:29:44 +08:00
|
|
|
ws.dumpCacheStats();
|
|
|
|
});
|
2013-03-18 23:37:31 +08:00
|
|
|
|
|
|
|
process.on('SIGUSR2', function() {
|
|
|
|
ws.dumpCacheStats();
|
|
|
|
});
|