I have an HTTP service written in Node.js
var server = http.createServer(function(request,response) {...}); server.listen(listenerPort);
When I deploy to Bluemix how/where do I assign a public endpoint and port#?
I have an HTTP service written in Node.js
var server = http.createServer(function(request,response) {...}); server.listen(listenerPort);
When I deploy to Bluemix how/where do I assign a public endpoint and port#?
Blumix provides an environment variable with the port.
// cfenv provides access to your Cloud Foundry environment
// for more info, see: https://www.npmjs.com/package/cfenv
var cfenv = require('cfenv');
// get the app environment from Cloud Foundry
var appEnv = cfenv.getAppEnv();
server.listen(appEnv.port);
When you are ready to deploy to Bluemix you can use the PORT environment variable accessible by using process.env.PORT
. There is also a npm package to help you with parsing Cloud Foundry environment variables like PORT
To decide the host name for your application- The app name will be the default host name. for example cf push myapp
will assign you the url myapp.mybluemix.net
You can also assign a host name using the host key in your manifest.yml OR using cf push myapp -n myhostname