Deployed Node app to OpenShift successfully, OpenShift still shows default page

不羁岁月 提交于 2019-12-11 13:18:35

问题


So here are the steps I've taken so far:

  1. Created application on openshift
  2. Cloned application's repo
  3. Deleted all files for the sample app in the cloned repo
  4. Added my project files
  5. Performed a Git-Push which completed successfully.

I still see the default landing page:

The only odd thing I see in the deployment logs this warning, which makes no senses because it's not my code doing that (I'm basically just trying to deploy the sample app from Express)

Any ideas as to what could be causing this? I'm trying to dump Heroku but can't get basic things to work.

UPDATE: I found this KB article which explains how to run your own file (why this information isn't better documented and part of the basic tutorial is beyond me). It is still unclear to me whether the code in server.js is needed or not... Or I'm expected to always use server.js as a shell to all my code.

https://www.openshift.com/kb/kb-e1048-how-can-i-run-my-own-nodejs-script


回答1:


I found the answer here:

https://www.openshift.com/blogs/run-your-nodejs-projects-on-openshift-in-two-simple-steps

The gist of it is this:

  • Change main in package.json to set main to yourApp.js (as per this article)
  • Make sure you're starting your server with the right IP and Port on OpenShift (see below)

app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080); app.set('ip', process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1');

and then

http.createServer(app).listen(app.get('port'), app.get('ip'), function(){ console.log('Express server listening on port ' + app.get('port')); });



来源:https://stackoverflow.com/questions/22582725/deployed-node-app-to-openshift-successfully-openshift-still-shows-default-page

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