added staging enviorment
This commit is contained in:
parent
8a407ef50d
commit
4874568c5c
@ -21,39 +21,39 @@ var PSQL = function(user_id, db, limit, offset){
|
||||
, limit: limit
|
||||
, offset: offset
|
||||
, client: null
|
||||
};
|
||||
|
||||
me.username = function(){
|
||||
var username = this.public_user;
|
||||
if (_.isString(this.user_id))
|
||||
username = _.template(global.settings.db_user, {user_id: this.user_id});
|
||||
|
||||
return username;
|
||||
};
|
||||
|
||||
me.database = function(){
|
||||
var database = db;
|
||||
|
||||
me.username = function(){
|
||||
var username = this.public_user;
|
||||
if (_.isString(this.user_id))
|
||||
username = _.template(global.settings.db_user, {user_id: this.user_id});
|
||||
|
||||
return username;
|
||||
};
|
||||
|
||||
me.database = function(){
|
||||
var database = db;
|
||||
if (_.isString(this.user_id))
|
||||
database = _.template(global.settings.db_base_name, {user_id: this.user_id});
|
||||
|
||||
|
||||
return database;
|
||||
};
|
||||
|
||||
|
||||
// memoizes connection in object. move to proper pool.
|
||||
me.connect = function(callback){
|
||||
var that = this
|
||||
var conString = "tcp://" + this.username() + "@" + global.settings.db_host + ":" + global.settings.db_port + "/" + this.database();
|
||||
|
||||
|
||||
if (that.client) {
|
||||
return callback(null, that.client);
|
||||
} else {
|
||||
pg.connect(conString, function(err, client){
|
||||
that.client = client;
|
||||
return callback(err, client);
|
||||
});
|
||||
return callback(err, client);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
me.query = function(sql, callback){
|
||||
var that = this;
|
||||
|
||||
@ -70,12 +70,12 @@ var PSQL = function(user_id, db, limit, offset){
|
||||
callback(err, res)
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
me.end = function(){
|
||||
this.client.end();
|
||||
};
|
||||
|
||||
|
||||
// little hack for UI
|
||||
me.window_sql = function(sql){
|
||||
// only window select functions
|
||||
@ -83,9 +83,9 @@ var PSQL = function(user_id, db, limit, offset){
|
||||
return "SELECT * FROM (" + sql + ") AS cdbq_1 LIMIT " + this.limit + " OFFSET " + this.offset;
|
||||
} else {
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return me;
|
||||
};
|
||||
|
||||
|
@ -14,9 +14,9 @@ var cluster = require('cluster');
|
||||
|
||||
// sanity check arguments
|
||||
var ENV = process.argv[2]
|
||||
if (ENV != 'development' && ENV != 'production') {
|
||||
if (ENV != 'development' && ENV != 'production' && ENV != 'test' && ENV != 'staging') {
|
||||
console.error("\n./cluster [environment]");
|
||||
console.error("environments: [development, test, production]");
|
||||
console.error("environments: [development, test, production, staging]");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@ -33,4 +33,4 @@ cluster('./app/controllers/app')
|
||||
.use(cluster.pidfiles('pids'))
|
||||
.listen(global.settings.node_port);
|
||||
|
||||
console.log('CartoDB SQL-API running on port: ' + global.settings.node_port);
|
||||
console.log('CartoDB SQL-API running on port: ' + global.settings.node_port);
|
||||
|
12
config/environments/staging.js
Normal file
12
config/environments/staging.js
Normal file
@ -0,0 +1,12 @@
|
||||
module.exports.node_port = 8080;
|
||||
module.exports.environment = 'staging';
|
||||
module.exports.db_base_name = 'cartodb_user_<%= user_id %>_db';
|
||||
module.exports.db_user = 'cartodb_user_<%= user_id %>';
|
||||
module.exports.db_host = 'localhost';
|
||||
module.exports.db_port = '6432';
|
||||
module.exports.redis_host = '127.0.0.1';
|
||||
module.exports.redis_port = 6379;
|
||||
module.exports.redisPool = 50;
|
||||
module.exports.redisIdleTimeoutMillis = 10000;
|
||||
module.exports.redisReapIntervalMillis = 1000;
|
||||
module.exports.redisLog = false;
|
Loading…
Reference in New Issue
Block a user