Skip to content

Instantly share code, notes, and snippets.

@primaryobjects
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save primaryobjects/8bd236b0763d2ff91bd6 to your computer and use it in GitHub Desktop.

Select an option

Save primaryobjects/8bd236b0763d2ff91bd6 to your computer and use it in GitHub Desktop.
Steps to deploy a node.js app on RedHat OpenShift: In app.js, call app.set() for the port and ip. In packages.json, set "main": "app.js"
app.configure(function() {
// Set the IP and port to use the OpenShift variables.
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || process.env.OPENSHIFT_INTERNAL_PORT || process.env.PORT || 3000);
app.set('ip', process.env.OPENSHIFT_NODEJS_IP || process.env.OPENSHIFT_INTERNAL_IP || 'localhost');
});
// ...
// Set the app.listen to use the port and ip.
app.listen(app.get('port'), app.get('ip'), function(){
console.log("Express server listening on " + app.get('ip') + ":" + app.get('port'));
});
{
"name": "your-app-name",
"version": "0.0.1",
"dependencies": {
"express": "3.4.0",
"ejs": "*",
"ejs-locals": "*",
"stylus": "*",
"mailer": "*"
},
"engines": {
"node": "0.10.17",
"npm": "1.3.x"
},
"main": "app.js"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment