I am trying to deploy expressjs app in openshift. In my app folder, I have copied my express js application folder. As per Deploying nodejs app with Open Shift PaaS, in app.js file of express application, I have added
app.set('port', 8080);
app.set('ipaddr', "a.b.c.d");
Also, in package.json, I have set value of 'main' key as app.js. I have also changed given express version to 4.8 . After pushing all the changes and node modules, when I hit my url, it says
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Can anyone please tell me what I am missing? AS per the error log below, sever is not reading at the given port i think:
Error: listen EACCES
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1020:19)
at listen (net.js:1061:10)
at Server.listen (net.js:1135:5)
at Object.<anonymous> (/var/lib/openshift/540091a45973ca08d9000732/app-root/runtime/repo/project1/app.js:18:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
DEBUG: Program node project1/app.js exited with code 8
I have even changed the app.js
to this
var server = http.createServer(app);
server.listen(process.env.OPENSHIFT_NODEJS_PORT || 8080);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080);
app.set('ipaddr', process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1");
Okkk...here is what i was doing wrong....
I needed to replace existing server listen code to this:
server.listen( port, ipaddress, function() {
console.log((new Date()) + ' Server is listening on port 8080');
});
In my app.js