Skip to content

Instantly share code, notes, and snippets.

@dulichan
Created March 16, 2014 02:28
Show Gist options
  • Save dulichan/9577696 to your computer and use it in GitHub Desktop.
Save dulichan/9577696 to your computer and use it in GitHub Desktop.
Get the runtime server address for jaggery application in the carbon environment
var getAddress = function(transport){
var process = require("process"),
host = process.getProperty('server.host'),
ip = process.getProperty('carbon.local.ip');
var log = new Log();
var port;
if(transport=="http"){
port = process.getProperty('mgt.transport.http.proxyPort');
if(!port){
//can use http.port as well
port = process.getProperty('mgt.transport.http.port');
}
}else if(transport=="https"){
port = process.getProperty('mgt.transport.https.proxyPort');
if(!port){
//can use https.port as well
port = process.getProperty('mgt.transport.https.port');
}
}
var postUrl;
if(host=="localhost"){
postUrl = "https://" + ip + ":" + port;
}else{
postUrl = "https://" + host+ ":" +port;
}
return postUrl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment