basic support for cloudfoundry.

Add
 - Entry point server.js
 - Load port and mysql configuraion from env variable
 - Tunable polling duration
This commit is contained in:
Andrew Liu 2011-08-24 21:59:50 +08:00
parent 7e4bba0e31
commit 95f1992e4d
4 changed files with 44 additions and 1 deletions

View file

@ -57,6 +57,11 @@ exports.abiword = null;
*/
exports.loglevel = "INFO";
/**
* xhr-polling duration
*/
exports.pollingDuration = 20;
//read the settings sync
var settingsStr = fs.readFileSync("../settings.json").toString();
@ -97,3 +102,31 @@ for(var i in settings)
console.warn("This setting doesn't exist or it was removed");
}
}
// If deployed in CloudFoundry
if(process.env.VCAP_APP_PORT) {
exports.port = process.env.VCAP_APP_PORT
}
// use mysql if provided.
var vcap_services = process.env.VCAP_SERVICES;
if(vcap_services) {
var svcs = JSON.parse(vcap_services)
for(var key in svcs ) {
var svc = svcs[key]
console.log("service:" + svc)
if( key.match(/^mysql/) ) {
exports.dbType= "mysql";
var cred = svc[0].credentials
exports.dbSettings = {
"user" : cred.user ,
"host" : cred.host ,
"password" : cred.password ,
"database" : cred.name ,
};
}
console.debug("database setup:" + console.dir(exports.dbSettings))
}
}