问题描述
因此,这是我到目前为止已采取的步骤:
So here are the steps I've taken so far:
- 在openshift上创建的应用程序
- 克隆应用程序的存储库
- 删除克隆存储库中示例应用程序的所有文件
- 添加了我的项目文件
- 执行了成功完成的Git-Push.
我仍然看到默认的登录页面:
I still see the default landing page:
我在部署中看到的唯一奇怪的东西记录了此警告,这毫无意义,因为这不是我的代码这样做(我基本上只是想从Express部署示例应用程序)
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)
关于什么可能导致这种情况的任何想法?我正在尝试转储Heroku,但无法使基本功能正常工作.
Any ideas as to what could be causing this? I'm trying to dump Heroku but can't get basic things to work.
更新:我找到了此知识库文章,该文章解释了如何运行自己的文件(为什么这些信息没有得到更好的记录,而基础教程的一部分超出了我的理解).对我来说还是不清楚的,是否需要server.js中的代码...或者希望我始终将server.js用作我所有代码的外壳.
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
推荐答案
我在这里找到了答案:
https://www.openshift.com/blogs/run-your-nodejs-projects-on-openshift-in-两个简单步骤
要点是:
- 更改package.json中的main以将 main 设置为yourApp.js(按照本文)
- 确保在OpenShift上使用正确的IP和端口启动服务器(请参见下文)
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080);app.set('ip', process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1');
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080);app.set('ip', process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1');
然后
http.createServer(app).listen(app.get('port'), app.get('ip'), function(){ console.log('Express server listening on port ' + app.get('port'));});
http.createServer(app).listen(app.get('port'), app.get('ip'), function(){ console.log('Express server listening on port ' + app.get('port'));});
这篇关于成功将节点应用程序部署到OpenShift,OpenShift仍显示默认页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!