2011-06-20 21:39:12 +08:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SQL API loader
|
|
|
|
* ===============
|
|
|
|
*
|
|
|
|
* node app [environment]
|
|
|
|
*
|
|
|
|
* environments: [development, test, production]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
var _ = require('underscore');
|
|
|
|
var cluster = require('cluster');
|
|
|
|
|
|
|
|
// sanity check arguments
|
|
|
|
var ENV = process.argv[2]
|
2011-09-16 19:43:10 +08:00
|
|
|
if (ENV != 'development' && ENV != 'production' && ENV != 'test' && ENV != 'staging') {
|
2011-08-23 21:58:06 +08:00
|
|
|
console.error("\n./cluster [environment]");
|
2011-09-16 19:43:10 +08:00
|
|
|
console.error("environments: [development, test, production, staging]");
|
2011-06-20 21:39:12 +08:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// set Node.js app settings and boot
|
|
|
|
global.settings = require(__dirname + '/config/settings')
|
|
|
|
var env = require(__dirname + '/config/environments/' + ENV)
|
|
|
|
_.extend(global.settings, env);
|
|
|
|
|
|
|
|
cluster('./app/controllers/app')
|
2011-09-07 19:10:16 +08:00
|
|
|
// .set('workers', 2)
|
|
|
|
// .set('socket path', '/tmp')
|
2011-06-20 21:39:12 +08:00
|
|
|
.use(cluster.logger('logs'))
|
|
|
|
.use(cluster.stats())
|
|
|
|
.use(cluster.pidfiles('pids'))
|
2011-06-30 19:13:13 +08:00
|
|
|
.listen(global.settings.node_port);
|
2011-09-05 07:49:46 +08:00
|
|
|
|
2011-09-16 19:43:10 +08:00
|
|
|
console.log('CartoDB SQL-API running on port: ' + global.settings.node_port);
|