Sunday 14 May 2017

Openshift not setting environment variable for node project

I have a simple node project that I am trying to get deployed to Openshift Online 3 but having some ip and port problems. Reading the documentation I need to get some environment variables from openshift system, seems legit. But Openshift doesn't seem to set the variables OPENSHIFT_NODEJS_PORT and OPENSHIFT_NODEJS_IP.

Using the example below:

var express = require('express');
var app = express();
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'
var port = process.env.OPENSHIFT_NODEJS_PORT || 1212

console.log('environment_port: ' + process.env.OPENSHIFT_NODEJS_PORT);
console.log('environment_ip: ' + process.env.OPENSHIFT_NODEJS_IP);

app.listen(port, server_ip_address, function (err) {
    console.log('Running on port ' + port + ' ip: ' + server_ip_address);
});

I get the following output from openshift logs:

enter image description here

Why isn't Openshift Online 3 setting the system varaibles?



via Andreas

No comments:

Post a Comment