Openshift node.js successful deployment, but “Application is not available”

删除回忆录丶 提交于 2019-12-24 09:49:10

问题


I'm having a problem getting a node.js app to run on Openshift.

I've set up my openshift project to pull from a git repo.

My server.listen call is being made like this:

var port = process.env.OPENSHIFT_NODEJS_PORT || process.env.PORT || 8080;
var ip = process.env.OPENSHIFT_NODEJS_IP || process.env.IP || '127.0.0.1';

var server = http.createServer(myServerFunction);
server.listen(port, ip);

The pull and build work fine. I can see in the pod terminal that my app is running because there is some console.log output indicating this. I can also see that neither process.env.OPENSHIFT_NODEJS_IP nor process.env.IP exist, and so the port has defaulted to 8080.

If I go into the pod's terminal and execute curl http://localhost:8080 I see precisely the html output I would expect from my app.

However, when I click on the overview tab and find the external url for my app (which is of the format http://<application>-<domain>.1d35.starter-us-east-1.openshiftapps.com), clicking that link results in openshift's "Application is not available" error page.

It seems to me that my node app is running perfectly well, but is not connected to the external url. I suspect that 8080 is not the correct port, and that I am required to do more configuration in order for my nodejs app to receive a value at process.env.OPENSHIFT_NODEJS_PORT.

In other stackoverflow answers I've also seen 0.0.0.0 as the default when process.env.OPENSHIFT_NODEJS_IP is not set. Could this make a difference?

Overall, how can I make the external url link to my nodejs server?

Thanks for any help!

来源:https://stackoverflow.com/questions/46267689/openshift-node-js-successful-deployment-but-application-is-not-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!