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
|
2011-10-08 00:28:07 +08:00
|
|
|
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
|
2011-10-08 00:28:07 +08:00
|
|
|
global.settings = require(__dirname + '/config/settings');
|
|
|
|
var env = require(__dirname + '/config/environments/' + ENV);
|
2011-06-20 21:39:12 +08:00
|
|
|
_.extend(global.settings, env);
|
|
|
|
|
|
|
|
cluster('./app/controllers/app')
|
|
|
|
.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);
|